mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Fix voice flow (#24825)
* Fix voice flow * Apply suggestions from code review --------- Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
parent
916dec101f
commit
e765cc10fb
@ -325,14 +325,16 @@ export class HaVoiceAssistantSetupStepLocal extends LitElement {
|
||||
(flow) =>
|
||||
flow.handler === "wyoming" &&
|
||||
flow.context.source === "hassio" &&
|
||||
(flow.context.configuration_url.includes(
|
||||
type === "tts" ? this._ttsHostName : this._sttHostName
|
||||
) ||
|
||||
flow.context.title_placeholders.title
|
||||
.toLowerCase()
|
||||
.includes(
|
||||
type === "tts" ? this._ttsProviderName : this._sttProviderName
|
||||
))
|
||||
((flow.context.configuration_url &&
|
||||
flow.context.configuration_url.includes(
|
||||
type === "tts" ? this._ttsAddonName : this._sttAddonName
|
||||
)) ||
|
||||
(flow.context.title_placeholders.title &&
|
||||
flow.context.title_placeholders.title
|
||||
.toLowerCase()
|
||||
.includes(
|
||||
type === "tts" ? this._ttsProviderName : this._sttProviderName
|
||||
)))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import {
|
||||
} from "../../data/assist_pipeline";
|
||||
import type { AssistSatelliteConfiguration } from "../../data/assist_satellite";
|
||||
import { fetchCloudStatus } from "../../data/cloud";
|
||||
import type { LanguageScores } from "../../data/conversation";
|
||||
import type { LanguageScore, LanguageScores } from "../../data/conversation";
|
||||
import { getLanguageScores, listAgents } from "../../data/conversation";
|
||||
import { listSTTEngines } from "../../data/stt";
|
||||
import { listTTSEngines, listTTSVoices } from "../../data/tts";
|
||||
@ -26,6 +26,12 @@ import { documentationUrl } from "../../util/documentation-url";
|
||||
|
||||
const OPTIONS = ["cloud", "focused_local", "full_local"] as const;
|
||||
|
||||
const EMPTY_SCORE: LanguageScore = {
|
||||
cloud: 0,
|
||||
focused_local: 0,
|
||||
full_local: 0,
|
||||
};
|
||||
|
||||
@customElement("ha-voice-assistant-setup-step-pipeline")
|
||||
export class HaVoiceAssistantSetupStepPipeline extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
@ -61,12 +67,12 @@ export class HaVoiceAssistantSetupStepPipeline extends LitElement {
|
||||
this._languageScores
|
||||
) {
|
||||
const lang = this.language;
|
||||
if (this._value && this._languageScores[lang][this._value] === 0) {
|
||||
if (this._value && this._languageScores[lang]?.[this._value] === 0) {
|
||||
this._value = undefined;
|
||||
}
|
||||
if (!this._value) {
|
||||
this._value = this._getOptions(
|
||||
this._languageScores[lang],
|
||||
this._languageScores[lang] || EMPTY_SCORE,
|
||||
this.hass.localize
|
||||
).supportedOptions[0]?.value as
|
||||
| "cloud"
|
||||
@ -147,12 +153,9 @@ export class HaVoiceAssistantSetupStepPipeline extends LitElement {
|
||||
</div>`;
|
||||
}
|
||||
|
||||
const score = this._languageScores[this.language];
|
||||
const score = this._languageScores[this.language] || EMPTY_SCORE;
|
||||
|
||||
const options = this._getOptions(
|
||||
score || { cloud: 3, focused_local: 0, full_local: 0 },
|
||||
this.hass.localize
|
||||
);
|
||||
const options = this._getOptions(score, this.hass.localize);
|
||||
|
||||
const performance = !this._value
|
||||
? ""
|
||||
@ -162,11 +165,11 @@ export class HaVoiceAssistantSetupStepPipeline extends LitElement {
|
||||
|
||||
const commands = !this._value
|
||||
? ""
|
||||
: score?.[this._value] > 2
|
||||
: score[this._value] > 2
|
||||
? "high"
|
||||
: score?.[this._value] > 1
|
||||
: score[this._value] > 1
|
||||
? "ready"
|
||||
: score?.[this._value] > 0
|
||||
: score[this._value] > 0
|
||||
? "low"
|
||||
: "";
|
||||
|
||||
|
@ -3431,9 +3431,9 @@
|
||||
},
|
||||
"local": {
|
||||
"title": "Installing add-ons",
|
||||
"secondary": "The Whisper and Piper add-ons are being installed and configured based on your hardware.",
|
||||
"secondary": "The add-ons for speech-to-text and text-to-speech are being installed and configured based on your hardware.",
|
||||
"failed_title": "Failed to install add-ons",
|
||||
"failed_secondary": "We were unable to install the Whisper and Piper add-ons automatically for you. Read the documentation to learn how to install them.",
|
||||
"failed_secondary": "We were unable to install the add-ons for speech-to-text and text-to-speech automatically for you. Read the documentation to learn how to install them.",
|
||||
"not_supported_title": "Installation of add-ons is not supported on your system",
|
||||
"not_supported_secondary": "Your system is not supported to automatically install a local TTS and STT provider. Learn how to set up local TTS and STT providers in the documentation.",
|
||||
"local_pipeline": "Local Assistant",
|
||||
|
Loading…
x
Reference in New Issue
Block a user