fix: iOS TTS unlock on user gesture, use \r for terminal Enter
Deploy Dashboard / deploy (push) Successful in 1m0s
Deploy Dashboard / deploy (push) Successful in 1m0s
This commit is contained in:
@@ -16,6 +16,7 @@ export class VoiceSession {
|
|||||||
this._debounce = null;
|
this._debounce = null;
|
||||||
this._recog = null;
|
this._recog = null;
|
||||||
this._onWriteDispose = null;
|
this._onWriteDispose = null;
|
||||||
|
this._ttsUnlocked = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get lang() { return LANGS[this.langIdx]; }
|
get lang() { return LANGS[this.langIdx]; }
|
||||||
@@ -68,10 +69,18 @@ export class VoiceSession {
|
|||||||
toggleTts() {
|
toggleTts() {
|
||||||
this.ttsEnabled = !this.ttsEnabled;
|
this.ttsEnabled = !this.ttsEnabled;
|
||||||
if (!this.ttsEnabled) { speechSynthesis.cancel(); this.speaking = false; }
|
if (!this.ttsEnabled) { speechSynthesis.cancel(); this.speaking = false; }
|
||||||
if (this.ttsEnabled && this.term) {
|
if (this.ttsEnabled) {
|
||||||
|
// iOS Safari requires first speak() in a user gesture to unlock audio
|
||||||
|
if (!this._ttsUnlocked) {
|
||||||
|
const u = new SpeechSynthesisUtterance("");
|
||||||
|
speechSynthesis.speak(u);
|
||||||
|
this._ttsUnlocked = true;
|
||||||
|
}
|
||||||
|
if (this.term) {
|
||||||
const buf = this.term.buffer.active;
|
const buf = this.term.buffer.active;
|
||||||
this._lastLine = buf.baseY + buf.cursorY;
|
this._lastLine = buf.baseY + buf.cursorY;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this._notify();
|
this._notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +102,7 @@ export class VoiceSession {
|
|||||||
if (e.results[i].isFinal) {
|
if (e.results[i].isFinal) {
|
||||||
const text = e.results[i][0].transcript.trim();
|
const text = e.results[i][0].transcript.trim();
|
||||||
if (text && this.ws?.readyState === 1) {
|
if (text && this.ws?.readyState === 1) {
|
||||||
this.ws.send(new TextEncoder().encode(text + "\n"));
|
this.ws.send(new TextEncoder().encode(text + "\r"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user