1 """Support for the demo for speech-to-text service."""
3 from __future__
import annotations
5 from collections.abc
import AsyncIterable
22 SUPPORT_LANGUAGES = [
"en",
"de"]
27 config_entry: ConfigEntry,
28 async_add_entities: AddEntitiesCallback,
30 """Set up Demo speech platform via config entry."""
35 """Demo speech API provider entity."""
37 _attr_name =
"Demo STT"
41 """Return a list of supported languages."""
42 return SUPPORT_LANGUAGES
46 """Return a list of supported formats."""
47 return [AudioFormats.WAV]
51 """Return a list of supported codecs."""
52 return [AudioCodecs.PCM]
56 """Return a list of supported bit rates."""
57 return [AudioBitRates.BITRATE_16]
61 """Return a list of supported sample rates."""
62 return [AudioSampleRates.SAMPLERATE_16000, AudioSampleRates.SAMPLERATE_44100]
66 """Return a list of supported channels."""
67 return [AudioChannels.CHANNEL_STEREO]
70 self, metadata: SpeechMetadata, stream: AsyncIterable[bytes]
72 """Process an audio stream to STT service."""
75 async
for _
in stream:
78 return SpeechResult(
"Turn the Kitchen Lights on", SpeechResultState.SUCCESS)
list[AudioCodecs] supported_codecs(self)
SpeechResult async_process_audio_stream(self, SpeechMetadata metadata, AsyncIterable[bytes] stream)
list[AudioFormats] supported_formats(self)
list[str] supported_languages(self)
list[AudioChannels] supported_channels(self)
list[AudioSampleRates] supported_sample_rates(self)
list[AudioBitRates] supported_bit_rates(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)