Convert async_get_conversation_languages from async to callback (#121162)
* Convert get_languages to callback * One more callback
This commit is contained in:
parent
cf96084ea3
commit
869f24df49
3 changed files with 10 additions and 8 deletions
|
@ -115,7 +115,8 @@ AUDIO_PROCESSOR_SAMPLES: Final = 160 # 10 ms @ 16 Khz
|
|||
AUDIO_PROCESSOR_BYTES: Final = AUDIO_PROCESSOR_SAMPLES * 2 # 16-bit samples
|
||||
|
||||
|
||||
async def _async_resolve_default_pipeline_settings(
|
||||
@callback
|
||||
def _async_resolve_default_pipeline_settings(
|
||||
hass: HomeAssistant,
|
||||
stt_engine_id: str | None,
|
||||
tts_engine_id: str | None,
|
||||
|
@ -139,7 +140,7 @@ async def _async_resolve_default_pipeline_settings(
|
|||
# Find a matching language supported by the Home Assistant conversation agent
|
||||
conversation_languages = language_util.matches(
|
||||
hass.config.language,
|
||||
await conversation.async_get_conversation_languages(
|
||||
conversation.async_get_conversation_languages(
|
||||
hass, conversation.HOME_ASSISTANT_AGENT
|
||||
),
|
||||
country=hass.config.country,
|
||||
|
@ -222,7 +223,7 @@ async def _async_create_default_pipeline(
|
|||
The default pipeline will use the homeassistant conversation agent and the
|
||||
default stt / tts engines.
|
||||
"""
|
||||
pipeline_settings = await _async_resolve_default_pipeline_settings(
|
||||
pipeline_settings = _async_resolve_default_pipeline_settings(
|
||||
hass, stt_engine_id=None, tts_engine_id=None, pipeline_name="Home Assistant"
|
||||
)
|
||||
return await pipeline_store.async_create_item(pipeline_settings)
|
||||
|
@ -241,7 +242,7 @@ async def async_create_default_pipeline(
|
|||
"""
|
||||
pipeline_data: PipelineData = hass.data[DOMAIN]
|
||||
pipeline_store = pipeline_data.pipeline_store
|
||||
pipeline_settings = await _async_resolve_default_pipeline_settings(
|
||||
pipeline_settings = _async_resolve_default_pipeline_settings(
|
||||
hass, stt_engine_id, tts_engine_id, pipeline_name=pipeline_name
|
||||
)
|
||||
if (
|
||||
|
|
|
@ -378,8 +378,8 @@ def websocket_get_run(
|
|||
vol.Required("type"): "assist_pipeline/language/list",
|
||||
}
|
||||
)
|
||||
@websocket_api.async_response
|
||||
async def websocket_list_languages(
|
||||
@callback
|
||||
def websocket_list_languages(
|
||||
hass: HomeAssistant,
|
||||
connection: websocket_api.connection.ActiveConnection,
|
||||
msg: dict[str, Any],
|
||||
|
@ -389,7 +389,7 @@ async def websocket_list_languages(
|
|||
This will return a list of languages which are supported by at least one stt, tts
|
||||
and conversation engine respectively.
|
||||
"""
|
||||
conv_language_tags = await conversation.async_get_conversation_languages(hass)
|
||||
conv_language_tags = conversation.async_get_conversation_languages(hass)
|
||||
stt_language_tags = stt.async_get_speech_to_text_languages(hass)
|
||||
tts_language_tags = tts.async_get_text_to_speech_languages(hass)
|
||||
pipeline_languages: set[str] | None = None
|
||||
|
|
|
@ -118,7 +118,8 @@ def async_unset_agent(
|
|||
get_agent_manager(hass).async_unset_agent(config_entry.entry_id)
|
||||
|
||||
|
||||
async def async_get_conversation_languages(
|
||||
@callback
|
||||
def async_get_conversation_languages(
|
||||
hass: HomeAssistant, agent_id: str | None = None
|
||||
) -> set[str] | Literal["*"]:
|
||||
"""Return languages supported by conversation agents.
|
||||
|
|
Loading…
Add table
Reference in a new issue