Home Assistant Unofficial Reference 2024.12.1
models.py
Go to the documentation of this file.
1 """Speech-to-text data models."""
2 
3 from dataclasses import dataclass
4 
5 from .const import (
6  AudioBitRates,
7  AudioChannels,
8  AudioCodecs,
9  AudioFormats,
10  AudioSampleRates,
11  SpeechResultState,
12 )
13 
14 
15 @dataclass
17  """Metadata of audio stream."""
18 
19  language: str
20  format: AudioFormats
21  codec: AudioCodecs
22  bit_rate: AudioBitRates
23  sample_rate: AudioSampleRates
24  channel: AudioChannels
25 
26  def __post_init__(self) -> None:
27  """Finish initializing the metadata."""
28  self.bit_ratebit_rate = AudioBitRates(int(self.bit_ratebit_rate))
29  self.sample_ratesample_rate = AudioSampleRates(int(self.sample_ratesample_rate))
30  self.channelchannel = AudioChannels(int(self.channelchannel))
31 
32 
33 @dataclass
35  """Result of audio Speech."""
36 
37  text: str | None
38  result: SpeechResultState