Standardize spelling of TTS and STT (#93857)
* Standardize spelling of TTS and STT * Apply suggestions from code review * Update homeassistant/components/tts/media_source.py --------- Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
b03dbeaed5
commit
c3a3ddcfa4
25 changed files with 57 additions and 57 deletions
|
@ -19,7 +19,7 @@ class PipelineNotFound(PipelineError):
|
||||||
|
|
||||||
|
|
||||||
class SpeechToTextError(PipelineError):
|
class SpeechToTextError(PipelineError):
|
||||||
"""Error in speech to text portion of pipeline."""
|
"""Error in speech-to-text portion of pipeline."""
|
||||||
|
|
||||||
|
|
||||||
class IntentRecognitionError(PipelineError):
|
class IntentRecognitionError(PipelineError):
|
||||||
|
@ -27,4 +27,4 @@ class IntentRecognitionError(PipelineError):
|
||||||
|
|
||||||
|
|
||||||
class TextToSpeechError(PipelineError):
|
class TextToSpeechError(PipelineError):
|
||||||
"""Error in text to speech portion of pipeline."""
|
"""Error in text-to-speech portion of pipeline."""
|
||||||
|
|
|
@ -125,7 +125,7 @@ async def _async_resolve_default_pipeline_settings(
|
||||||
stt_language = stt_languages[0]
|
stt_language = stt_languages[0]
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Speech to text engine '%s' does not support language '%s'",
|
"Speech-to-text engine '%s' does not support language '%s'",
|
||||||
stt_engine_id,
|
stt_engine_id,
|
||||||
pipeline_language,
|
pipeline_language,
|
||||||
)
|
)
|
||||||
|
@ -152,7 +152,7 @@ async def _async_resolve_default_pipeline_settings(
|
||||||
tts_voice = tts_voices[0].voice_id
|
tts_voice = tts_voices[0].voice_id
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"Text to speech engine '%s' does not support language '%s'",
|
"Text-to-speech engine '%s' does not support language '%s'",
|
||||||
tts_engine_id,
|
tts_engine_id,
|
||||||
pipeline_language,
|
pipeline_language,
|
||||||
)
|
)
|
||||||
|
@ -387,7 +387,7 @@ class PipelineRun:
|
||||||
)
|
)
|
||||||
|
|
||||||
async def prepare_speech_to_text(self, metadata: stt.SpeechMetadata) -> None:
|
async def prepare_speech_to_text(self, metadata: stt.SpeechMetadata) -> None:
|
||||||
"""Prepare speech to text."""
|
"""Prepare speech-to-text."""
|
||||||
# pipeline.stt_engine can't be None or this function is not called
|
# pipeline.stt_engine can't be None or this function is not called
|
||||||
stt_provider = stt.async_get_speech_to_text_engine(
|
stt_provider = stt.async_get_speech_to_text_engine(
|
||||||
self.hass,
|
self.hass,
|
||||||
|
@ -398,7 +398,7 @@ class PipelineRun:
|
||||||
engine = self.pipeline.stt_engine
|
engine = self.pipeline.stt_engine
|
||||||
raise SpeechToTextError(
|
raise SpeechToTextError(
|
||||||
code="stt-provider-missing",
|
code="stt-provider-missing",
|
||||||
message=f"No speech to text provider for: {engine}",
|
message=f"No speech-to-text provider for: {engine}",
|
||||||
)
|
)
|
||||||
|
|
||||||
metadata.language = self.pipeline.stt_language or self.language
|
metadata.language = self.pipeline.stt_language or self.language
|
||||||
|
@ -419,7 +419,7 @@ class PipelineRun:
|
||||||
metadata: stt.SpeechMetadata,
|
metadata: stt.SpeechMetadata,
|
||||||
stream: AsyncIterable[bytes],
|
stream: AsyncIterable[bytes],
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Run speech to text portion of pipeline. Returns the spoken text."""
|
"""Run speech-to-text portion of pipeline. Returns the spoken text."""
|
||||||
if isinstance(self.stt_provider, stt.Provider):
|
if isinstance(self.stt_provider, stt.Provider):
|
||||||
engine = self.stt_provider.name
|
engine = self.stt_provider.name
|
||||||
else:
|
else:
|
||||||
|
@ -441,10 +441,10 @@ class PipelineRun:
|
||||||
metadata, stream
|
metadata, stream
|
||||||
)
|
)
|
||||||
except Exception as src_error:
|
except Exception as src_error:
|
||||||
_LOGGER.exception("Unexpected error during speech to text")
|
_LOGGER.exception("Unexpected error during speech-to-text")
|
||||||
raise SpeechToTextError(
|
raise SpeechToTextError(
|
||||||
code="stt-stream-failed",
|
code="stt-stream-failed",
|
||||||
message="Unexpected error during speech to text",
|
message="Unexpected error during speech-to-text",
|
||||||
) from src_error
|
) from src_error
|
||||||
|
|
||||||
_LOGGER.debug("speech-to-text result %s", result)
|
_LOGGER.debug("speech-to-text result %s", result)
|
||||||
|
@ -452,7 +452,7 @@ class PipelineRun:
|
||||||
if result.result != stt.SpeechResultState.SUCCESS:
|
if result.result != stt.SpeechResultState.SUCCESS:
|
||||||
raise SpeechToTextError(
|
raise SpeechToTextError(
|
||||||
code="stt-stream-failed",
|
code="stt-stream-failed",
|
||||||
message="Speech to text failed",
|
message="speech-to-text failed",
|
||||||
)
|
)
|
||||||
|
|
||||||
if not result.text:
|
if not result.text:
|
||||||
|
@ -541,7 +541,7 @@ class PipelineRun:
|
||||||
return speech
|
return speech
|
||||||
|
|
||||||
async def prepare_text_to_speech(self) -> None:
|
async def prepare_text_to_speech(self) -> None:
|
||||||
"""Prepare text to speech."""
|
"""Prepare text-to-speech."""
|
||||||
# pipeline.tts_engine can't be None or this function is not called
|
# pipeline.tts_engine can't be None or this function is not called
|
||||||
engine = cast(str, self.pipeline.tts_engine)
|
engine = cast(str, self.pipeline.tts_engine)
|
||||||
|
|
||||||
|
@ -562,13 +562,13 @@ class PipelineRun:
|
||||||
except HomeAssistantError as err:
|
except HomeAssistantError as err:
|
||||||
raise TextToSpeechError(
|
raise TextToSpeechError(
|
||||||
code="tts-not-supported",
|
code="tts-not-supported",
|
||||||
message=f"Text to speech engine '{engine}' not found",
|
message=f"Text-to-speech engine '{engine}' not found",
|
||||||
) from err
|
) from err
|
||||||
if not options_supported:
|
if not options_supported:
|
||||||
raise TextToSpeechError(
|
raise TextToSpeechError(
|
||||||
code="tts-not-supported",
|
code="tts-not-supported",
|
||||||
message=(
|
message=(
|
||||||
f"Text to speech engine {engine} "
|
f"Text-to-speech engine {engine} "
|
||||||
f"does not support language {self.pipeline.tts_language} or options {tts_options}"
|
f"does not support language {self.pipeline.tts_language} or options {tts_options}"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -577,7 +577,7 @@ class PipelineRun:
|
||||||
self.tts_options = tts_options
|
self.tts_options = tts_options
|
||||||
|
|
||||||
async def text_to_speech(self, tts_input: str) -> str:
|
async def text_to_speech(self, tts_input: str) -> str:
|
||||||
"""Run text to speech portion of pipeline. Returns URL of TTS audio."""
|
"""Run text-to-speech portion of pipeline. Returns URL of TTS audio."""
|
||||||
self.process_event(
|
self.process_event(
|
||||||
PipelineEvent(
|
PipelineEvent(
|
||||||
PipelineEventType.TTS_START,
|
PipelineEventType.TTS_START,
|
||||||
|
@ -605,10 +605,10 @@ class PipelineRun:
|
||||||
None,
|
None,
|
||||||
)
|
)
|
||||||
except Exception as src_error:
|
except Exception as src_error:
|
||||||
_LOGGER.exception("Unexpected error during text to speech")
|
_LOGGER.exception("Unexpected error during text-to-speech")
|
||||||
raise TextToSpeechError(
|
raise TextToSpeechError(
|
||||||
code="tts-failed",
|
code="tts-failed",
|
||||||
message="Unexpected error during text to speech",
|
message="Unexpected error during text-to-speech",
|
||||||
) from src_error
|
) from src_error
|
||||||
|
|
||||||
_LOGGER.debug("TTS result %s", tts_media)
|
_LOGGER.debug("TTS result %s", tts_media)
|
||||||
|
@ -644,7 +644,7 @@ class PipelineInput:
|
||||||
"""Input for conversation agent. Required when start_stage = intent."""
|
"""Input for conversation agent. Required when start_stage = intent."""
|
||||||
|
|
||||||
tts_input: str | None = None
|
tts_input: str | None = None
|
||||||
"""Input for text to speech. Required when start_stage = tts."""
|
"""Input for text-to-speech. Required when start_stage = tts."""
|
||||||
|
|
||||||
conversation_id: str | None = None
|
conversation_id: str | None = None
|
||||||
|
|
||||||
|
@ -654,7 +654,7 @@ class PipelineInput:
|
||||||
current_stage = self.run.start_stage
|
current_stage = self.run.start_stage
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Speech to text
|
# speech-to-text
|
||||||
intent_input = self.intent_input
|
intent_input = self.intent_input
|
||||||
if current_stage == PipelineStage.STT:
|
if current_stage == PipelineStage.STT:
|
||||||
assert self.stt_metadata is not None
|
assert self.stt_metadata is not None
|
||||||
|
@ -696,15 +696,15 @@ class PipelineInput:
|
||||||
if self.run.start_stage == PipelineStage.STT:
|
if self.run.start_stage == PipelineStage.STT:
|
||||||
if self.run.pipeline.stt_engine is None:
|
if self.run.pipeline.stt_engine is None:
|
||||||
raise PipelineRunValidationError(
|
raise PipelineRunValidationError(
|
||||||
"the pipeline does not support speech to text"
|
"the pipeline does not support speech-to-text"
|
||||||
)
|
)
|
||||||
if self.stt_metadata is None:
|
if self.stt_metadata is None:
|
||||||
raise PipelineRunValidationError(
|
raise PipelineRunValidationError(
|
||||||
"stt_metadata is required for speech to text"
|
"stt_metadata is required for speech-to-text"
|
||||||
)
|
)
|
||||||
if self.stt_stream is None:
|
if self.stt_stream is None:
|
||||||
raise PipelineRunValidationError(
|
raise PipelineRunValidationError(
|
||||||
"stt_stream is required for speech to text"
|
"stt_stream is required for speech-to-text"
|
||||||
)
|
)
|
||||||
elif self.run.start_stage == PipelineStage.INTENT:
|
elif self.run.start_stage == PipelineStage.INTENT:
|
||||||
if self.intent_input is None:
|
if self.intent_input is None:
|
||||||
|
@ -714,12 +714,12 @@ class PipelineInput:
|
||||||
elif self.run.start_stage == PipelineStage.TTS:
|
elif self.run.start_stage == PipelineStage.TTS:
|
||||||
if self.tts_input is None:
|
if self.tts_input is None:
|
||||||
raise PipelineRunValidationError(
|
raise PipelineRunValidationError(
|
||||||
"tts_input is required for text to speech"
|
"tts_input is required for text-to-speech"
|
||||||
)
|
)
|
||||||
if self.run.end_stage == PipelineStage.TTS:
|
if self.run.end_stage == PipelineStage.TTS:
|
||||||
if self.run.pipeline.tts_engine is None:
|
if self.run.pipeline.tts_engine is None:
|
||||||
raise PipelineRunValidationError(
|
raise PipelineRunValidationError(
|
||||||
"the pipeline does not support text to speech"
|
"the pipeline does not support text-to-speech"
|
||||||
)
|
)
|
||||||
|
|
||||||
start_stage_index = PIPELINE_STAGE_ORDER.index(self.run.start_stage)
|
start_stage_index = PIPELINE_STAGE_ORDER.index(self.run.start_stage)
|
||||||
|
|
|
@ -151,7 +151,7 @@ async def websocket_run(
|
||||||
# Input to conversation agent
|
# Input to conversation agent
|
||||||
input_args["intent_input"] = msg["input"]["text"]
|
input_args["intent_input"] = msg["input"]["text"]
|
||||||
elif start_stage == PipelineStage.TTS:
|
elif start_stage == PipelineStage.TTS:
|
||||||
# Input to text to speech system
|
# Input to text-to-speech system
|
||||||
input_args["tts_input"] = msg["input"]["text"]
|
input_args["tts_input"] = msg["input"]["text"]
|
||||||
|
|
||||||
input_args["run"] = PipelineRun(
|
input_args["run"] = PipelineRun(
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Support for the cloud for text to speech service."""
|
"""Support for the cloud for text-to-speech service."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Support for the demo for speech to text service."""
|
"""Support for the demo for speech-to-text service."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import AsyncIterable
|
from collections.abc import AsyncIterable
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Support for the demo for text to speech service."""
|
"""Support for the demo for text-to-speech service."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"domain": "google_translate",
|
"domain": "google_translate",
|
||||||
"name": "Google Translate Text-to-Speech",
|
"name": "Google Translate text-to-speech",
|
||||||
"codeowners": [],
|
"codeowners": [],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/google_translate",
|
"documentation": "https://www.home-assistant.io/integrations/google_translate",
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
|
|
|
@ -413,7 +413,7 @@ def _metadata_from_header(request: web.Request) -> SpeechMetadata:
|
||||||
def websocket_list_engines(
|
def websocket_list_engines(
|
||||||
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
|
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
|
||||||
) -> None:
|
) -> None:
|
||||||
"""List speech to text engines and, optionally, if they support a given language."""
|
"""List speech-to-text engines and, optionally, if they support a given language."""
|
||||||
component: EntityComponent[SpeechToTextEntity] = hass.data[DOMAIN]
|
component: EntityComponent[SpeechToTextEntity] = hass.data[DOMAIN]
|
||||||
legacy_providers: dict[str, Provider] = hass.data[DATA_PROVIDERS]
|
legacy_providers: dict[str, Provider] = hass.data[DATA_PROVIDERS]
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Handle legacy speech to text platforms."""
|
"""Handle legacy speech-to-text platforms."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
|
@ -51,7 +51,7 @@ def async_get_provider(
|
||||||
def async_setup_legacy(
|
def async_setup_legacy(
|
||||||
hass: HomeAssistant, config: ConfigType
|
hass: HomeAssistant, config: ConfigType
|
||||||
) -> list[Coroutine[Any, Any, None]]:
|
) -> list[Coroutine[Any, Any, None]]:
|
||||||
"""Set up legacy speech to text providers."""
|
"""Set up legacy speech-to-text providers."""
|
||||||
providers = hass.data[DATA_PROVIDERS] = {}
|
providers = hass.data[DATA_PROVIDERS] = {}
|
||||||
|
|
||||||
async def async_setup_platform(p_type, p_config=None, discovery_info=None):
|
async def async_setup_platform(p_type, p_config=None, discovery_info=None):
|
||||||
|
@ -61,7 +61,7 @@ def async_setup_legacy(
|
||||||
|
|
||||||
platform = await async_prepare_setup_platform(hass, config, DOMAIN, p_type)
|
platform = await async_prepare_setup_platform(hass, config, DOMAIN, p_type)
|
||||||
if platform is None:
|
if platform is None:
|
||||||
_LOGGER.error("Unknown speech to text platform specified")
|
_LOGGER.error("Unknown speech-to-text platform specified")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"domain": "stt",
|
"domain": "stt",
|
||||||
"name": "Speech-to-Text (STT)",
|
"name": "Speech-to-text (STT)",
|
||||||
"codeowners": ["@home-assistant/core", "@pvizeli"],
|
"codeowners": ["@home-assistant/core", "@pvizeli"],
|
||||||
"dependencies": ["http"],
|
"dependencies": ["http"],
|
||||||
"documentation": "https://www.home-assistant.io/integrations/stt",
|
"documentation": "https://www.home-assistant.io/integrations/stt",
|
||||||
|
|
|
@ -112,7 +112,7 @@ SCHEMA_SERVICE_SAY = vol.Schema(
|
||||||
async def async_setup_legacy(
|
async def async_setup_legacy(
|
||||||
hass: HomeAssistant, config: ConfigType
|
hass: HomeAssistant, config: ConfigType
|
||||||
) -> list[Coroutine[Any, Any, None]]:
|
) -> list[Coroutine[Any, Any, None]]:
|
||||||
"""Set up legacy text to speech providers."""
|
"""Set up legacy text-to-speech providers."""
|
||||||
tts: SpeechManager = hass.data[DATA_TTS_MANAGER]
|
tts: SpeechManager = hass.data[DATA_TTS_MANAGER]
|
||||||
|
|
||||||
# Load service descriptions from tts/services.yaml
|
# Load service descriptions from tts/services.yaml
|
||||||
|
@ -132,7 +132,7 @@ async def async_setup_legacy(
|
||||||
|
|
||||||
platform = await async_prepare_setup_platform(hass, config, DOMAIN, p_type)
|
platform = await async_prepare_setup_platform(hass, config, DOMAIN, p_type)
|
||||||
if platform is None:
|
if platform is None:
|
||||||
_LOGGER.error("Unknown text to speech platform specified")
|
_LOGGER.error("Unknown text-to-speech platform specified")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"domain": "tts",
|
"domain": "tts",
|
||||||
"name": "Text-to-Speech (TTS)",
|
"name": "Text-to-speech (TTS)",
|
||||||
"after_dependencies": ["media_player"],
|
"after_dependencies": ["media_player"],
|
||||||
"codeowners": ["@home-assistant/core", "@pvizeli"],
|
"codeowners": ["@home-assistant/core", "@pvizeli"],
|
||||||
"dependencies": ["http"],
|
"dependencies": ["http"],
|
||||||
|
|
|
@ -104,7 +104,7 @@ def media_source_id_to_kwargs(media_source_id: str) -> MediaSourceOptions:
|
||||||
class TTSMediaSource(MediaSource):
|
class TTSMediaSource(MediaSource):
|
||||||
"""Provide text-to-speech providers as media sources."""
|
"""Provide text-to-speech providers as media sources."""
|
||||||
|
|
||||||
name: str = "Text to Speech"
|
name: str = "Text-to-speech"
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistant) -> None:
|
def __init__(self, hass: HomeAssistant) -> None:
|
||||||
"""Initialize TTSMediaSource."""
|
"""Initialize TTSMediaSource."""
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Support for Wyoming speech to text services."""
|
"""Support for Wyoming speech-to-text services."""
|
||||||
from collections.abc import AsyncIterable
|
from collections.abc import AsyncIterable
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ async def async_setup_entry(
|
||||||
config_entry: ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Wyoming speech to text."""
|
"""Set up Wyoming speech-to-text."""
|
||||||
service: WyomingService = hass.data[DOMAIN][config_entry.entry_id]
|
service: WyomingService = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
|
@ -33,7 +33,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
|
|
||||||
class WyomingSttProvider(stt.SpeechToTextEntity):
|
class WyomingSttProvider(stt.SpeechToTextEntity):
|
||||||
"""Wyoming speech to text provider."""
|
"""Wyoming speech-to-text provider."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Support for Wyoming text to speech services."""
|
"""Support for Wyoming text-to-speech services."""
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import io
|
import io
|
||||||
import logging
|
import logging
|
||||||
|
@ -25,7 +25,7 @@ async def async_setup_entry(
|
||||||
config_entry: ConfigEntry,
|
config_entry: ConfigEntry,
|
||||||
async_add_entities: AddEntitiesCallback,
|
async_add_entities: AddEntitiesCallback,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Wyoming speech to text."""
|
"""Set up Wyoming speech-to-text."""
|
||||||
service: WyomingService = hass.data[DOMAIN][config_entry.entry_id]
|
service: WyomingService = hass.data[DOMAIN][config_entry.entry_id]
|
||||||
async_add_entities(
|
async_add_entities(
|
||||||
[
|
[
|
||||||
|
@ -35,7 +35,7 @@ async def async_setup_entry(
|
||||||
|
|
||||||
|
|
||||||
class WyomingTtsProvider(tts.TextToSpeechEntity):
|
class WyomingTtsProvider(tts.TextToSpeechEntity):
|
||||||
"""Wyoming text to speech provider."""
|
"""Wyoming text-to-speech provider."""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -96,7 +96,7 @@ default_config:
|
||||||
frontend:
|
frontend:
|
||||||
themes: !include_dir_merge_named themes
|
themes: !include_dir_merge_named themes
|
||||||
|
|
||||||
# Text to speech
|
# Text-to-speech
|
||||||
tts:
|
tts:
|
||||||
- platform: google_translate
|
- platform: google_translate
|
||||||
|
|
||||||
|
|
|
@ -2080,7 +2080,7 @@
|
||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
"config_flow": false,
|
"config_flow": false,
|
||||||
"iot_class": "cloud_push",
|
"iot_class": "cloud_push",
|
||||||
"name": "Google Translate Text-to-Speech"
|
"name": "Google Translate text-to-speech"
|
||||||
},
|
},
|
||||||
"google_travel_time": {
|
"google_travel_time": {
|
||||||
"integration_type": "hub",
|
"integration_type": "hub",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Helper script to update supported languages for Microsoft Text-to-Speech (TTS)."""
|
"""Helper script to update supported languages for Microsoft text-to-speech (TTS)."""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from lxml import html
|
from lxml import html
|
||||||
|
|
|
@ -132,7 +132,7 @@ async def test_audio_pipeline(
|
||||||
assert msg["event"]["data"] == snapshot
|
assert msg["event"]["data"] == snapshot
|
||||||
events.append(msg["event"])
|
events.append(msg["event"])
|
||||||
|
|
||||||
# text to speech
|
# text-to-speech
|
||||||
msg = await client.receive_json()
|
msg = await client.receive_json()
|
||||||
assert msg["event"]["type"] == "tts-start"
|
assert msg["event"]["type"] == "tts-start"
|
||||||
assert msg["event"]["data"] == snapshot
|
assert msg["event"]["data"] == snapshot
|
||||||
|
@ -532,7 +532,7 @@ async def test_tts_failed(
|
||||||
init_components,
|
init_components,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test pipeline run with text to speech error."""
|
"""Test pipeline run with text-to-speech error."""
|
||||||
events = []
|
events = []
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
|
@ -595,7 +595,7 @@ async def test_tts_provider_missing(
|
||||||
mock_tts_provider,
|
mock_tts_provider,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test pipeline run with text to speech error."""
|
"""Test pipeline run with text-to-speech error."""
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -624,7 +624,7 @@ async def test_tts_provider_bad_options(
|
||||||
mock_tts_provider,
|
mock_tts_provider,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test pipeline run with text to speech error."""
|
"""Test pipeline run with text-to-speech error."""
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
with patch(
|
with patch(
|
||||||
|
@ -1227,7 +1227,7 @@ async def test_audio_pipeline_debug(
|
||||||
assert msg["event"]["data"] == snapshot
|
assert msg["event"]["data"] == snapshot
|
||||||
events.append(msg["event"])
|
events.append(msg["event"])
|
||||||
|
|
||||||
# text to speech
|
# text-to-speech
|
||||||
msg = await client.receive_json()
|
msg = await client.receive_json()
|
||||||
assert msg["event"]["type"] == "tts-start"
|
assert msg["event"]["type"] == "tts-start"
|
||||||
assert msg["event"]["data"] == snapshot
|
assert msg["event"]["data"] == snapshot
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
"""Tests for the Microsoft Text-to-Speech component."""
|
"""Tests for the Microsoft text-to-speech component."""
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
"""Tests for Microsoft Text-to-Speech."""
|
"""Tests for Microsoft text-to-speech."""
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from pycsspeechtts import pycsspeechtts
|
from pycsspeechtts import pycsspeechtts
|
||||||
|
|
|
@ -392,7 +392,7 @@ async def test_ws_list_engines(
|
||||||
setup: MockProvider | MockProviderEntity,
|
setup: MockProvider | MockProviderEntity,
|
||||||
engine_id: str,
|
engine_id: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test listing speech to text engines."""
|
"""Test listing speech-to-text engines."""
|
||||||
client = await hass_ws_client()
|
client = await hass_ws_client()
|
||||||
|
|
||||||
await client.send_json_auto_id({"type": "stt/engine/list"})
|
await client.send_json_auto_id({"type": "stt/engine/list"})
|
||||||
|
|
|
@ -26,7 +26,7 @@ async def test_invalid_platform(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert "Unknown speech to text platform specified" in caplog.text
|
assert "Unknown speech-to-text platform specified" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_platform_setup_with_error(
|
async def test_platform_setup_with_error(
|
||||||
|
|
|
@ -71,7 +71,7 @@ async def test_invalid_platform(
|
||||||
)
|
)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert "Unknown text to speech platform specified" in caplog.text
|
assert "Unknown text-to-speech platform specified" in caplog.text
|
||||||
|
|
||||||
|
|
||||||
async def test_platform_setup_without_provider(
|
async def test_platform_setup_without_provider(
|
||||||
|
|
|
@ -52,7 +52,7 @@ async def test_browsing(hass: HomeAssistant, setup: str) -> None:
|
||||||
item = await media_source.async_browse_media(hass, "media-source://tts")
|
item = await media_source.async_browse_media(hass, "media-source://tts")
|
||||||
|
|
||||||
assert item is not None
|
assert item is not None
|
||||||
assert item.title == "Text to Speech"
|
assert item.title == "Text-to-speech"
|
||||||
assert item.children is not None
|
assert item.children is not None
|
||||||
assert len(item.children) == 1
|
assert len(item.children) == 1
|
||||||
assert item.can_play is False
|
assert item.can_play is False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue