fix(audio): longer Piper time for long calls, fallback voice matches the line's language (1.55.2)
This commit is contained in:
1 parent
c3aafba327
commit
36fe1e3933
6 files changed
+21
-8
No files matched your search
@@ -8,6 +8,13 @@ The application version is maintained in `package.json` and displayed in the adm
|
||||
|
||||
No changes recorded yet.
|
||||
|
||||
## 1.55.2 - 2026-11-03
|
||||
|
||||
### Fixed
|
||||
|
||||
- A long call (a heat call with every driver's name) gets more time to be made by Piper before the browser's voice takes over; short calls such as the count-down keep the short limit.
|
||||
- The browser's voice (used when Piper can't answer in time) only uses the voice chosen in Settings when it speaks the line's language, so a Swedish voice no longer reads an English call.
|
||||
|
||||
## 1.55.1 - 2026-11-03
|
||||
|
||||
### Fixed
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.55.1",
|
||||
"version": "1.55.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "rc-racecore",
|
||||
"version": "1.55.1",
|
||||
"version": "1.55.2",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"better-sqlite3": "^12.11.1",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "rc-racecore",
|
||||
"version": "1.55.1",
|
||||
"version": "1.55.2",
|
||||
"private": true,
|
||||
"description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence",
|
||||
"engines": {
|
||||
|
||||
+4
-1
@@ -28,7 +28,10 @@ export function speakWithPiper(text, { language, voice = "", rate, volume = 1, i
|
||||
if (current === job) current = null;
|
||||
callback?.();
|
||||
};
|
||||
const timer = setTimeout(() => job.controller.abort(), PIPER_TIMEOUT_MS);
|
||||
// Short calls (count-down) must be on time; a long line such as a heat call with every
|
||||
// driver's name gets longer to be generated before the browser voice takes over.
|
||||
const timeoutMs = PIPER_TIMEOUT_MS + Math.min(7500, Math.max(0, String(text || "").length - 40) * 60);
|
||||
const timer = setTimeout(() => job.controller.abort(), timeoutMs);
|
||||
fetch("/api/tts/speech", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
||||
@@ -364,9 +364,11 @@ export function getSpeechVoicesHelper() {
|
||||
|
||||
export function selectSpeechVoice(voices, voiceUri, language) {
|
||||
const items = Array.isArray(voices) ? voices : [];
|
||||
const selected = items.find((voice) => voice.voiceURI === voiceUri);
|
||||
if (selected) return selected;
|
||||
const prefix = String(language || "").toLowerCase().split("-")[0];
|
||||
// The chosen voice only when it speaks this line's language: a Swedish voice must not read
|
||||
// an English call (and the other way round).
|
||||
const selected = items.find((voice) => voice.voiceURI === voiceUri);
|
||||
if (selected && (!prefix || String(selected.lang || "").toLowerCase().startsWith(prefix))) return selected;
|
||||
return items.find((voice) => String(voice.lang || "").toLowerCase().startsWith(prefix) && voice.localService !== false)
|
||||
|| items.find((voice) => String(voice.lang || "").toLowerCase().startsWith(prefix))
|
||||
|| null;
|
||||
|
||||
@@ -8,13 +8,14 @@ import {
|
||||
speakTextHelper,
|
||||
} from "../src/runtime_services.js";
|
||||
|
||||
test("speech voice selection prefers an explicit voice and then the current language", () => {
|
||||
test("speech voice selection prefers the chosen voice when it speaks the line's language, else the language", () => {
|
||||
const voices = [
|
||||
{ name: "English", lang: "en-US", voiceURI: "voice-en", localService: true },
|
||||
{ name: "Swedish", lang: "sv-SE", voiceURI: "voice-sv", localService: true },
|
||||
];
|
||||
|
||||
assert.equal(selectSpeechVoice(voices, "voice-en", "sv-SE")?.voiceURI, "voice-en");
|
||||
assert.equal(selectSpeechVoice(voices, "voice-en", "en-US")?.voiceURI, "voice-en");
|
||||
assert.equal(selectSpeechVoice(voices, "voice-sv", "en-US")?.voiceURI, "voice-en", "a Swedish voice never reads an English line");
|
||||
assert.equal(selectSpeechVoice(voices, "", "sv-SE")?.voiceURI, "voice-sv");
|
||||
assert.equal(selectSpeechVoice(voices, "missing", "de-DE"), null);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user