From 0e071a8b7ef6e83a6929814d5718323237951dc5 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Tue, 2 May 2023 14:34:47 +0200 Subject: [PATCH] disabled microphone button when not supported --- .../ha-voice-command-dialog.ts | 49 ++++++++++++------- src/translations/en.json | 1 + 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts b/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts index 87ea70b4e5..fc81faea15 100644 --- a/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts +++ b/src/dialogs/voice-command-dialog/ha-voice-command-dialog.ts @@ -1,3 +1,4 @@ +import "@lrnwebcomponents/simple-tooltip/simple-tooltip"; import "@material/mwc-button/mwc-button"; import { mdiChevronDown, @@ -109,7 +110,6 @@ export class HaVoiceCommandDialog extends LitElement { if (!this._opened) { return nothing; } - const supportsSTT = this._pipeline?.stt_engine && AudioRecorder.isSupported; return html` - +
${this._showSendButton ? html` ` - : supportsSTT - ? html` + : this._pipeline?.stt_engine + ? html`
${this._audioRecorder?.active ? html`
@@ -226,17 +227,28 @@ export class HaVoiceCommandDialog extends LitElement { ` : ""} - ` + ${!AudioRecorder.isSupported + ? html`${this.hass.localize( + "ui.dialogs.voice_command.stt_not_supported" + )}` + : ""} +
` : ""} - +
${this._agentInfo && this._agentInfo.attribution ? html` @@ -561,18 +573,20 @@ export class HaVoiceCommandDialog extends LitElement { return [ haStyleDialog, css` - ha-icon-button.listening-icon { + #microphone-button { color: var(--secondary-text-color); - margin-right: -24px; - margin-inline-end: -24px; - margin-inline-start: initial; direction: var(--direction); } - - ha-icon-button.listening-icon[active] { + #microphone-button[active] { color: var(--primary-color); } - + .move-end { + position: relative; + right: -24px; + } + simple-tooltip { + top: 0; + } ha-dialog { --primary-action-button-flex: 1; --secondary-action-button-flex: 0; @@ -622,7 +636,6 @@ export class HaVoiceCommandDialog extends LitElement { } ha-textfield { display: block; - overflow: hidden; } a.button { text-decoration: none; diff --git a/src/translations/en.json b/src/translations/en.json index fa194a5049..d725f6692d 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -838,6 +838,7 @@ "input_label": "Enter a request", "send_text": "Send text", "start_listening": "Start listening", + "stt_not_supported": "You can only use speech-to-text when using HTTPS.", "manage_assistants": "Manage assistants" }, "generic": {