Home Assistant Unofficial Reference 2024.12.1
homeassistant.components.tts.SpeechManager Class Reference

Public Member Functions

None __init__ (self, HomeAssistant hass, bool use_cache, str cache_dir, int time_memory)
 
None async_clear_cache (self)
 
tuple[str, bytes] async_get_tts_audio (self, str engine, str message, bool|None cache=None, str|None language=None, dict|None options=None)
 
str async_get_url_path (self, str engine, str message, bool|None cache=None, str|None language=None, dict|None options=None)
 
None async_init_cache (self)
 
tuple[str|None, bytes] async_read_tts (self, str token)
 
None async_register_legacy_engine (self, str engine, Provider provider, ConfigType config)
 
tuple[str, dict[str, Any]] process_options (self, TextToSpeechEntity|Provider engine_instance, str|None language, dict|None options)
 

Static Public Member Functions

bytes write_tags (str filename, bytes data, str engine_name, str message, str language, dict|None options)
 

Public Attributes

 cache_dir
 
 file_cache
 
 hass
 
 mem_cache
 
 time_memory
 
 use_cache
 

Private Member Functions

None _async_file_to_mem (self, str cache_key)
 
str _async_get_tts_audio (self, TextToSpeechEntity|Provider engine_instance, str cache_key, str message, bool cache, str language, dict[str, Any] options)
 
None _async_save_tts_audio (self, str cache_key, str filename, bytes data)
 
None _async_store_to_memcache (self, str cache_key, str filename, bytes data)
 
str _generate_cache_key (self, str message, str language, dict|None options, str engine)
 
dict[str, str] _init_cache (self)
 

Detailed Description

Representation of a speech store.

Definition at line 524 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.components.tts.SpeechManager.__init__ (   self,
HomeAssistant  hass,
bool  use_cache,
str  cache_dir,
int  time_memory 
)
Initialize a speech store.

Definition at line 527 of file __init__.py.

Member Function Documentation

◆ _async_file_to_mem()

None homeassistant.components.tts.SpeechManager._async_file_to_mem (   self,
str  cache_key 
)
private
Load voice from file cache into memory.

This method is a coroutine.

Definition at line 879 of file __init__.py.

◆ _async_get_tts_audio()

str homeassistant.components.tts.SpeechManager._async_get_tts_audio (   self,
TextToSpeechEntity | Provider  engine_instance,
str  cache_key,
str  message,
bool  cache,
str  language,
dict[str, Any]  options 
)
private
Receive TTS, store for view in cache and return filename.

This method is a coroutine.

Definition at line 723 of file __init__.py.

◆ _async_save_tts_audio()

None homeassistant.components.tts.SpeechManager._async_save_tts_audio (   self,
str  cache_key,
str  filename,
bytes   data 
)
private
Store voice data to file and file_cache.

This method is a coroutine.

Definition at line 859 of file __init__.py.

◆ _async_store_to_memcache()

None homeassistant.components.tts.SpeechManager._async_store_to_memcache (   self,
str  cache_key,
str  filename,
bytes   data 
)
private
Store data to memcache and set timer to remove it.

Definition at line 903 of file __init__.py.

◆ _generate_cache_key()

str homeassistant.components.tts.SpeechManager._generate_cache_key (   self,
str  message,
str  language,
dict | None  options,
str  engine 
)
private
Generate a cache key for a message.

Definition at line 709 of file __init__.py.

◆ _init_cache()

dict[str, str] homeassistant.components.tts.SpeechManager._init_cache (   self)
private
Init cache folder and fetch files.

Definition at line 548 of file __init__.py.

◆ async_clear_cache()

None homeassistant.components.tts.SpeechManager.async_clear_cache (   self)
Read file cache and delete files.

Definition at line 564 of file __init__.py.

◆ async_get_tts_audio()

tuple[str, bytes] homeassistant.components.tts.SpeechManager.async_get_tts_audio (   self,
str  engine,
str  message,
bool | None   cache = None,
str | None   language = None,
dict | None   options = None 
)
Fetch TTS audio.

Definition at line 676 of file __init__.py.

◆ async_get_url_path()

str homeassistant.components.tts.SpeechManager.async_get_url_path (   self,
str  engine,
str  message,
bool | None   cache = None,
str | None   language = None,
dict | None   options = None 
)
Get URL for play message.

This method is a coroutine.

Definition at line 632 of file __init__.py.

◆ async_init_cache()

None homeassistant.components.tts.SpeechManager.async_init_cache (   self)
Init config folder and load file cache.

Definition at line 560 of file __init__.py.

◆ async_read_tts()

tuple[str | None, bytes] homeassistant.components.tts.SpeechManager.async_read_tts (   self,
str  token 
)
Read a voice file and return binary.

This method is a coroutine.

Definition at line 928 of file __init__.py.

◆ async_register_legacy_engine()

None homeassistant.components.tts.SpeechManager.async_register_legacy_engine (   self,
str  engine,
Provider  provider,
ConfigType   config 
)
Register a legacy TTS engine.

Definition at line 580 of file __init__.py.

◆ process_options()

tuple[str, dict[str, Any]] homeassistant.components.tts.SpeechManager.process_options (   self,
TextToSpeechEntity | Provider  engine_instance,
str | None  language,
dict | None  options 
)
Validate and process options.

Definition at line 594 of file __init__.py.

◆ write_tags()

bytes homeassistant.components.tts.SpeechManager.write_tags ( str  filename,
bytes  data,
str  engine_name,
str  message,
str  language,
dict | None  options 
)
static
Write ID3 tags to file.

Async friendly.

Definition at line 960 of file __init__.py.

Member Data Documentation

◆ cache_dir

homeassistant.components.tts.SpeechManager.cache_dir

Definition at line 539 of file __init__.py.

◆ file_cache

homeassistant.components.tts.SpeechManager.file_cache

Definition at line 577 of file __init__.py.

◆ hass

homeassistant.components.tts.SpeechManager.hass

Definition at line 535 of file __init__.py.

◆ mem_cache

homeassistant.components.tts.SpeechManager.mem_cache

Definition at line 566 of file __init__.py.

◆ time_memory

homeassistant.components.tts.SpeechManager.time_memory

Definition at line 540 of file __init__.py.

◆ use_cache

homeassistant.components.tts.SpeechManager.use_cache

Definition at line 538 of file __init__.py.


The documentation for this class was generated from the following file: