Offer speech retry after iOS playback errors
Build and publish frontend / publish (push) Successful in 43s

This commit is contained in:
Ein Anderssono
2026-10-16 00:40:52 +02:00
parent cc17b501cc
commit c5c0fb6b03
3 changed files with 17 additions and 3 deletions
+1 -1
View File
@@ -219,7 +219,7 @@
microphone.textContent = listening ? 'Avsluta mikrofon' : 'Starta mikrofon';
refreshMicrophone();
if (message) setVoiceStatus(message);
if (/Uppläsningen startade inte/.test(message)) showSpeechRecovery(message);
if (/Läs senaste repliken/.test(message)) showSpeechRecovery(message);
playVoiceSignal(state === 'IDLE' && /Mikrofonen är avstängd/.test(message) ? 'STOPPED' : state);
},
onTranscript(text) {
+10
View File
@@ -165,6 +165,16 @@ test('speech start timeout tells the player how to recover when mobile playback
assert.equal(h.synthesis.cancelled, cancelledBeforeRetry);
});
test('iOS not-allowed speech error offers an immediate gesture-based retry', () => {
const h = makeHarness();
h.controller.speak('En replik');
h.utterances[0].onerror({error: 'not-allowed'});
assert.match(h.states.at(-1).message, /Safari blockerade uppläsningen/);
assert.match(h.states.at(-1).message, /Läs senaste repliken/);
assert.equal(h.controller.speak('Försök igen'), true);
assert.equal(h.synthesis.spoken.at(-1).text, 'Försök igen');
});
test('character voice identity gives stable distinct masculine, feminine, and neutral timbres', () => {
const profile = GameVoice.characterVoiceProfile;
const masculine = profile('masculine', 'character-1');
+6 -2
View File
@@ -240,7 +240,7 @@
currentUtterance = null;
setState('IDLE');
};
utterance.onerror = () => {
utterance.onerror = event => {
if (token !== generation) return;
if (speechTimer !== null) win.clearTimeout(speechTimer);
if (speechStartTimer !== null) win.clearTimeout(speechStartTimer);
@@ -248,7 +248,11 @@
speechStartTimer = null;
currentUtterance = null;
generation += 1;
setState('IDLE', 'Uppläsningen avbröts. Dialogen finns kvar som text.');
const blocked = event?.error === 'not-allowed' || event?.error === 'service-not-allowed';
const message = blocked
? 'Safari blockerade uppläsningen. Tryck på Läs senaste repliken för att starta ljudet.'
: 'Uppläsningen avbröts. Tryck på Läs senaste repliken för att försöka igen. Dialogen finns kvar som text.';
setState('IDLE', message);
};
setState('SPEAKING', 'Läser upp dialog.');
currentUtterance = utterance;