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:
c0ffeeca7 2023-05-31 17:00:19 +02:00 committed by GitHub
parent b03dbeaed5
commit c3a3ddcfa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 57 additions and 57 deletions

View file

@ -19,7 +19,7 @@ class PipelineNotFound(PipelineError):
class SpeechToTextError(PipelineError):
"""Error in speech to text portion of pipeline."""
"""Error in speech-to-text portion of pipeline."""
class IntentRecognitionError(PipelineError):
@ -27,4 +27,4 @@ class IntentRecognitionError(PipelineError):
class TextToSpeechError(PipelineError):
"""Error in text to speech portion of pipeline."""
"""Error in text-to-speech portion of pipeline."""

View file

@ -125,7 +125,7 @@ async def _async_resolve_default_pipeline_settings(
stt_language = stt_languages[0]
else:
_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,
pipeline_language,
)
@ -152,7 +152,7 @@ async def _async_resolve_default_pipeline_settings(
tts_voice = tts_voices[0].voice_id
else:
_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,
pipeline_language,
)
@ -387,7 +387,7 @@ class PipelineRun:
)
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
stt_provider = stt.async_get_speech_to_text_engine(
self.hass,
@ -398,7 +398,7 @@ class PipelineRun:
engine = self.pipeline.stt_engine
raise SpeechToTextError(
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
@ -419,7 +419,7 @@ class PipelineRun:
metadata: stt.SpeechMetadata,
stream: AsyncIterable[bytes],
) -> 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):
engine = self.stt_provider.name
else:
@ -441,10 +441,10 @@ class PipelineRun:
metadata, stream
)
except Exception as src_error:
_LOGGER.exception("Unexpected error during speech to text")
_LOGGER.exception("Unexpected error during speech-to-text")
raise SpeechToTextError(
code="stt-stream-failed",
message="Unexpected error during speech to text",
message="Unexpected error during speech-to-text",
) from src_error
_LOGGER.debug("speech-to-text result %s", result)
@ -452,7 +452,7 @@ class PipelineRun:
if result.result != stt.SpeechResultState.SUCCESS:
raise SpeechToTextError(
code="stt-stream-failed",
message="Speech to text failed",
message="speech-to-text failed",
)
if not result.text:
@ -541,7 +541,7 @@ class PipelineRun:
return speech
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
engine = cast(str, self.pipeline.tts_engine)
@ -562,13 +562,13 @@ class PipelineRun:
except HomeAssistantError as err:
raise TextToSpeechError(
code="tts-not-supported",
message=f"Text to speech engine '{engine}' not found",
message=f"Text-to-speech engine '{engine}' not found",
) from err
if not options_supported:
raise TextToSpeechError(
code="tts-not-supported",
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}"
),
)
@ -577,7 +577,7 @@ class PipelineRun:
self.tts_options = tts_options
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(
PipelineEvent(
PipelineEventType.TTS_START,
@ -605,10 +605,10 @@ class PipelineRun:
None,
)
except Exception as src_error:
_LOGGER.exception("Unexpected error during text to speech")
_LOGGER.exception("Unexpected error during text-to-speech")
raise TextToSpeechError(
code="tts-failed",
message="Unexpected error during text to speech",
message="Unexpected error during text-to-speech",
) from src_error
_LOGGER.debug("TTS result %s", tts_media)
@ -644,7 +644,7 @@ class PipelineInput:
"""Input for conversation agent. Required when start_stage = intent."""
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
@ -654,7 +654,7 @@ class PipelineInput:
current_stage = self.run.start_stage
try:
# Speech to text
# speech-to-text
intent_input = self.intent_input
if current_stage == PipelineStage.STT:
assert self.stt_metadata is not None
@ -696,15 +696,15 @@ class PipelineInput:
if self.run.start_stage == PipelineStage.STT:
if self.run.pipeline.stt_engine is None:
raise PipelineRunValidationError(
"the pipeline does not support speech to text"
"the pipeline does not support speech-to-text"
)
if self.stt_metadata is None:
raise PipelineRunValidationError(
"stt_metadata is required for speech to text"
"stt_metadata is required for speech-to-text"
)
if self.stt_stream is None:
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:
if self.intent_input is None:
@ -714,12 +714,12 @@ class PipelineInput:
elif self.run.start_stage == PipelineStage.TTS:
if self.tts_input is None:
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.pipeline.tts_engine is None:
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)

View file

@ -151,7 +151,7 @@ async def websocket_run(
# Input to conversation agent
input_args["intent_input"] = msg["input"]["text"]
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["run"] = PipelineRun(

View file

@ -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
import logging

View file

@ -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 collections.abc import AsyncIterable

View file

@ -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
import os

View file

@ -1,6 +1,6 @@
{
"domain": "google_translate",
"name": "Google Translate Text-to-Speech",
"name": "Google Translate text-to-speech",
"codeowners": [],
"documentation": "https://www.home-assistant.io/integrations/google_translate",
"iot_class": "cloud_push",

View file

@ -413,7 +413,7 @@ def _metadata_from_header(request: web.Request) -> SpeechMetadata:
def websocket_list_engines(
hass: HomeAssistant, connection: websocket_api.ActiveConnection, msg: dict
) -> 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]
legacy_providers: dict[str, Provider] = hass.data[DATA_PROVIDERS]

View file

@ -1,4 +1,4 @@
"""Handle legacy speech to text platforms."""
"""Handle legacy speech-to-text platforms."""
from __future__ import annotations
from abc import ABC, abstractmethod
@ -51,7 +51,7 @@ def async_get_provider(
def async_setup_legacy(
hass: HomeAssistant, config: ConfigType
) -> list[Coroutine[Any, Any, None]]:
"""Set up legacy speech to text providers."""
"""Set up legacy speech-to-text providers."""
providers = hass.data[DATA_PROVIDERS] = {}
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)
if platform is None:
_LOGGER.error("Unknown speech to text platform specified")
_LOGGER.error("Unknown speech-to-text platform specified")
return
try:

View file

@ -1,6 +1,6 @@
{
"domain": "stt",
"name": "Speech-to-Text (STT)",
"name": "Speech-to-text (STT)",
"codeowners": ["@home-assistant/core", "@pvizeli"],
"dependencies": ["http"],
"documentation": "https://www.home-assistant.io/integrations/stt",

View file

@ -112,7 +112,7 @@ SCHEMA_SERVICE_SAY = vol.Schema(
async def async_setup_legacy(
hass: HomeAssistant, config: ConfigType
) -> 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]
# 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)
if platform is None:
_LOGGER.error("Unknown text to speech platform specified")
_LOGGER.error("Unknown text-to-speech platform specified")
return
try:

View file

@ -1,6 +1,6 @@
{
"domain": "tts",
"name": "Text-to-Speech (TTS)",
"name": "Text-to-speech (TTS)",
"after_dependencies": ["media_player"],
"codeowners": ["@home-assistant/core", "@pvizeli"],
"dependencies": ["http"],

View file

@ -104,7 +104,7 @@ def media_source_id_to_kwargs(media_source_id: str) -> MediaSourceOptions:
class TTSMediaSource(MediaSource):
"""Provide text-to-speech providers as media sources."""
name: str = "Text to Speech"
name: str = "Text-to-speech"
def __init__(self, hass: HomeAssistant) -> None:
"""Initialize TTSMediaSource."""

View file

@ -1,4 +1,4 @@
"""Support for Wyoming speech to text services."""
"""Support for Wyoming speech-to-text services."""
from collections.abc import AsyncIterable
import logging
@ -23,7 +23,7 @@ async def async_setup_entry(
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Wyoming speech to text."""
"""Set up Wyoming speech-to-text."""
service: WyomingService = hass.data[DOMAIN][config_entry.entry_id]
async_add_entities(
[
@ -33,7 +33,7 @@ async def async_setup_entry(
class WyomingSttProvider(stt.SpeechToTextEntity):
"""Wyoming speech to text provider."""
"""Wyoming speech-to-text provider."""
def __init__(
self,

View file

@ -1,4 +1,4 @@
"""Support for Wyoming text to speech services."""
"""Support for Wyoming text-to-speech services."""
from collections import defaultdict
import io
import logging
@ -25,7 +25,7 @@ async def async_setup_entry(
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up Wyoming speech to text."""
"""Set up Wyoming speech-to-text."""
service: WyomingService = hass.data[DOMAIN][config_entry.entry_id]
async_add_entities(
[
@ -35,7 +35,7 @@ async def async_setup_entry(
class WyomingTtsProvider(tts.TextToSpeechEntity):
"""Wyoming text to speech provider."""
"""Wyoming text-to-speech provider."""
def __init__(
self,

View file

@ -96,7 +96,7 @@ default_config:
frontend:
themes: !include_dir_merge_named themes
# Text to speech
# Text-to-speech
tts:
- platform: google_translate

View file

@ -2080,7 +2080,7 @@
"integration_type": "hub",
"config_flow": false,
"iot_class": "cloud_push",
"name": "Google Translate Text-to-Speech"
"name": "Google Translate text-to-speech"
},
"google_travel_time": {
"integration_type": "hub",

View file

@ -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 lxml import html

View file

@ -132,7 +132,7 @@ async def test_audio_pipeline(
assert msg["event"]["data"] == snapshot
events.append(msg["event"])
# text to speech
# text-to-speech
msg = await client.receive_json()
assert msg["event"]["type"] == "tts-start"
assert msg["event"]["data"] == snapshot
@ -532,7 +532,7 @@ async def test_tts_failed(
init_components,
snapshot: SnapshotAssertion,
) -> None:
"""Test pipeline run with text to speech error."""
"""Test pipeline run with text-to-speech error."""
events = []
client = await hass_ws_client(hass)
@ -595,7 +595,7 @@ async def test_tts_provider_missing(
mock_tts_provider,
snapshot: SnapshotAssertion,
) -> None:
"""Test pipeline run with text to speech error."""
"""Test pipeline run with text-to-speech error."""
client = await hass_ws_client(hass)
with patch(
@ -624,7 +624,7 @@ async def test_tts_provider_bad_options(
mock_tts_provider,
snapshot: SnapshotAssertion,
) -> None:
"""Test pipeline run with text to speech error."""
"""Test pipeline run with text-to-speech error."""
client = await hass_ws_client(hass)
with patch(
@ -1227,7 +1227,7 @@ async def test_audio_pipeline_debug(
assert msg["event"]["data"] == snapshot
events.append(msg["event"])
# text to speech
# text-to-speech
msg = await client.receive_json()
assert msg["event"]["type"] == "tts-start"
assert msg["event"]["data"] == snapshot

View file

@ -1 +1 @@
"""Tests for the Microsoft Text-to-Speech component."""
"""Tests for the Microsoft text-to-speech component."""

View file

@ -1,4 +1,4 @@
"""Tests for Microsoft Text-to-Speech."""
"""Tests for Microsoft text-to-speech."""
from unittest.mock import patch
from pycsspeechtts import pycsspeechtts

View file

@ -392,7 +392,7 @@ async def test_ws_list_engines(
setup: MockProvider | MockProviderEntity,
engine_id: str,
) -> None:
"""Test listing speech to text engines."""
"""Test listing speech-to-text engines."""
client = await hass_ws_client()
await client.send_json_auto_id({"type": "stt/engine/list"})

View file

@ -26,7 +26,7 @@ async def test_invalid_platform(
)
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(

View file

@ -71,7 +71,7 @@ async def test_invalid_platform(
)
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(

View file

@ -52,7 +52,7 @@ async def test_browsing(hass: HomeAssistant, setup: str) -> None:
item = await media_source.async_browse_media(hass, "media-source://tts")
assert item is not None
assert item.title == "Text to Speech"
assert item.title == "Text-to-speech"
assert item.children is not None
assert len(item.children) == 1
assert item.can_play is False