feat(audio): speak lap times as seconds and hundredths, "18 sixty-three" (1.89.2)
This commit is contained in:
1 parent
379dd52c7f
commit
dd2fc6bd89
7 files changed
+37
-14
No files matched your search
@@ -8,6 +8,10 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
No changes recorded yet.
|
||||
|
||||
## 1.89.2
|
||||
|
||||
- Announcements say a lap time as a speaker does: seconds and hundredths as two numbers, "18 sixty-three" / "18 sextiotre" (was "18 six three"), and "18 flat" / "18 jämnt" on .00. Gaps keep the decimal mark ("0,30").
|
||||
|
||||
## 1.89.1
|
||||
|
||||
- Fix: the app loaded as a blank page after 1.89.0 (a quote in a guide text broke app.js). A new test checks that every file in src/ parses.
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.1",
|
||||
"version": "1.89.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.1",
|
||||
"version": "1.89.2",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^12.11.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.89.1",
|
||||
"version": "1.89.2",
|
||||
"private": true,
|
||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||
"engines": {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { getControlledLapStreak } from "./training_logic.js";
|
||||
import { usesPersonalClock, getLatestClockStartTs } from "./prologue_logic.js";
|
||||
import { isSuspectLap, getSuspectReferenceLaps, releaseSettledSuspectLaps } from "./suspect_laps_logic.js";
|
||||
import { shouldCallPracticePersonalBest } from "./practice_callouts_logic.js";
|
||||
import { normalizeRaceAudioSettings, formatSpokenLapTime, formatShortLapCall, LEADER_UPDATE_INTERVAL_MS } from "./race_audio.js";
|
||||
import { normalizeRaceAudioSettings, formatSpokenLapTime, formatSpokenGap, formatShortLapCall, LEADER_UPDATE_INTERVAL_MS } from "./race_audio.js";
|
||||
import { findDriverByCarTransponder } from "./sponsor_event_logic.js";
|
||||
import { confirmLeaderChange } from "./leader_call_logic.js";
|
||||
import { pickPracticeHype, getDriverLapTimes, getClassRank, getLastTimeBestMs, findDuelRival } from "./practice_hype_logic.js";
|
||||
@@ -46,7 +46,7 @@ function buildPracticeHype({ state, session, result, entry, key, lapMs, previous
|
||||
const en = language === "en";
|
||||
const v = pick.variables;
|
||||
const variables = { driverName: spokenName(entry), laps: v.laps, rival: v.rival };
|
||||
if (v.gapMs !== undefined) variables.gap = formatSpokenLapTime(Math.max(10, v.gapMs), language);
|
||||
if (v.gapMs !== undefined) variables.gap = formatSpokenGap(Math.max(10, v.gapMs), language);
|
||||
if (v.avgMs) variables.avgLap = formatSpokenLapTime(v.avgMs, language);
|
||||
if (v.rank) variables.rank = (en ? ["the fastest", "second fastest", "third fastest"] : ["snabbast", "näst snabbast", "tredje snabbast"])[v.rank - 1];
|
||||
if (v.ahead !== undefined) variables.relation = v.ahead ? (en ? "ahead of" : "före") : (en ? "behind" : "efter");
|
||||
|
||||
+18
-2
@@ -150,9 +150,25 @@ export function formatShortLapCall(ms, language = "sv") {
|
||||
return minutes ? `${minutes} ${String(seconds).padStart(2, "0")} ${tenth}` : `${seconds} ${tenth}`;
|
||||
}
|
||||
|
||||
// A lap time as the speaker says it: "17,18" (sv) / "17.18" (en), not "0:17.180", which voices
|
||||
// read as "zero 17 comma 180". Hundredths, cut not rounded, as on the timing screens.
|
||||
// A lap time as a speaker says it: seconds and hundredths as two numbers, "18 63" -> "18
|
||||
// sixty-three" ("18 sextiotre"), not "0:18.630" or "18 point six three". Over a minute:
|
||||
// "1 minut 05 32". Hundredths are cut, not rounded, as on the timing screens.
|
||||
export function formatSpokenLapTime(ms, language = "sv") {
|
||||
const value = Math.max(0, Math.floor(Number(ms) || 0));
|
||||
if (!value) return "";
|
||||
const minutes = Math.floor(value / 60000);
|
||||
const seconds = Math.floor((value % 60000) / 1000);
|
||||
// "00" would be read "hundred" by some voices: say "flat" / "jämnt" as on the passing call.
|
||||
const cut = Math.floor((value % 1000) / 10);
|
||||
const hundredths = cut ? String(cut).padStart(2, "0") : TENTHS[language === "en" ? "en" : "sv"][0];
|
||||
if (!minutes) return `${seconds} ${hundredths}`;
|
||||
const word = language === "en" ? (minutes === 1 ? "minute" : "minutes") : (minutes === 1 ? "minut" : "minuter");
|
||||
return `${minutes} ${word} ${String(seconds).padStart(2, "0")} ${hundredths}`;
|
||||
}
|
||||
|
||||
// A gap or other short time with a decimal mark: "0,30" (sv) / "0.30" (en), read as "zero
|
||||
// point three zero" - a gap said as "0 30" would sound like a clock.
|
||||
export function formatSpokenGap(ms, language = "sv") {
|
||||
const value = Math.max(0, Math.floor(Number(ms) || 0));
|
||||
if (!value) return "";
|
||||
const minutes = Math.floor(value / 60000);
|
||||
|
||||
@@ -68,7 +68,7 @@ test("five controlled practice laps trigger one stable-pace voice cue", () => {
|
||||
for (let lap = 1; lap <= 5; lap += 1) harness.passing(1_000 + lap * 20_000, "main");
|
||||
assert.equal(harness.audioEvents.filter((event) => event === "training_stable_pace").length, 1);
|
||||
const call = harness.audioCalls.find((item) => item.key === "training_stable_pace");
|
||||
assert.equal(call.variables.avgLap, "20,00");
|
||||
assert.equal(call.variables.avgLap, "20 jämnt");
|
||||
});
|
||||
|
||||
test("stable-pace training cue is never emitted during a race", () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { RACE_AUDIO_EVENT_DEFINITIONS, createRaceAudioEngine, normalizeRaceAudioSettings, isSilencedDuringRace, formatSpokenLapTime, formatShortLapCall } from "../src/race_audio.js";
|
||||
import { RACE_AUDIO_EVENT_DEFINITIONS, createRaceAudioEngine, normalizeRaceAudioSettings, isSilencedDuringRace, formatSpokenLapTime, formatSpokenGap, formatShortLapCall } from "../src/race_audio.js";
|
||||
|
||||
const manifest = {
|
||||
events: { transponder_pass: { effect: "effects/transponder_pass.wav" }, start_tone: { effect: "effects/start_beep.wav" } },
|
||||
@@ -331,11 +331,14 @@ test("the start and finish signals are chosen in Settings: tone and stop signal
|
||||
});
|
||||
|
||||
test("lap times are spoken as seconds with hundredths, no leading zero minute", () => {
|
||||
assert.equal(formatSpokenLapTime(17189, "sv"), "17,18");
|
||||
assert.equal(formatSpokenLapTime(17189, "en"), "17.18");
|
||||
assert.equal(formatSpokenLapTime(9050, "sv"), "9,05");
|
||||
assert.equal(formatSpokenLapTime(65320, "sv"), "1 minut 5,32");
|
||||
assert.equal(formatSpokenLapTime(125000, "en"), "2 minutes 5.00");
|
||||
assert.equal(formatSpokenLapTime(18639, "sv"), "18 63");
|
||||
assert.equal(formatSpokenLapTime(18639, "en"), "18 63");
|
||||
assert.equal(formatSpokenLapTime(9050, "sv"), "9 05");
|
||||
assert.equal(formatSpokenLapTime(65320, "sv"), "1 minut 05 32");
|
||||
assert.equal(formatSpokenLapTime(125000, "en"), "2 minutes 05 flat");
|
||||
assert.equal(formatSpokenLapTime(18004, "sv"), "18 jämnt");
|
||||
assert.equal(formatSpokenGap(300, "sv"), "0,30");
|
||||
assert.equal(formatSpokenGap(1250, "en"), "1.25");
|
||||
});
|
||||
|
||||
test("practice hype calls only sound in practice and can be turned off", () => {
|
||||
|
||||
Reference in new issue
Block a user