mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Fix tts in voice command for iOS (#16300)
This commit is contained in:
parent
8a50bb058d
commit
2498f1db41
@ -89,14 +89,7 @@ export class HaVoiceCommandDialog extends LitElement {
|
|||||||
this._conversationId = null;
|
this._conversationId = null;
|
||||||
this._audioRecorder?.close();
|
this._audioRecorder?.close();
|
||||||
this._audioRecorder = undefined;
|
this._audioRecorder = undefined;
|
||||||
if (this._audio) {
|
this._audio?.pause();
|
||||||
this._audio.pause();
|
|
||||||
this._audio.removeEventListener("ended", this._unloadAudio);
|
|
||||||
this._audio.removeEventListener("pause", this._unloadAudio);
|
|
||||||
this._audio.removeEventListener("canplaythrough", this._playAudio);
|
|
||||||
this._audio.removeEventListener("error", this._audioError);
|
|
||||||
this._audio = undefined;
|
|
||||||
}
|
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,15 +371,12 @@ export class HaVoiceCommandDialog extends LitElement {
|
|||||||
|
|
||||||
if (event.type === "tts-end") {
|
if (event.type === "tts-end") {
|
||||||
const url = event.data.tts_output.url;
|
const url = event.data.tts_output.url;
|
||||||
if (!this._audio) {
|
this._audio = new Audio(url);
|
||||||
this._audio = new Audio(url);
|
this._audio.play();
|
||||||
this._audio.addEventListener("ended", this._unloadAudio);
|
this._audio.addEventListener("ended", this._unloadAudio);
|
||||||
this._audio.addEventListener("pause", this._unloadAudio);
|
this._audio.addEventListener("pause", this._unloadAudio);
|
||||||
this._audio.addEventListener("canplaythrough", this._playAudio);
|
this._audio.addEventListener("canplaythrough", this._playAudio);
|
||||||
this._audio.addEventListener("error", this._audioError);
|
this._audio.addEventListener("error", this._audioError);
|
||||||
} else {
|
|
||||||
this._audio.src = url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.type === "run-end") {
|
if (event.type === "run-end") {
|
||||||
@ -466,6 +456,7 @@ export class HaVoiceCommandDialog extends LitElement {
|
|||||||
|
|
||||||
private _unloadAudio = () => {
|
private _unloadAudio = () => {
|
||||||
this._audio?.removeAttribute("src");
|
this._audio?.removeAttribute("src");
|
||||||
|
this._audio = undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
private _scrollMessagesBottom() {
|
private _scrollMessagesBottom() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user