Rename voice_assistant to assist_pipeline (#91371)

* Rename voice_assistant to assist_pipeline

* Fix tests

* Fix voip test

---------

Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Erik Montnemery
2023-04-13 23:25:38 +02:00
committed by GitHub
parent 32344a8488
commit 4e80154ebe
23 changed files with 63 additions and 63 deletions

View File

@ -105,6 +105,8 @@ build.json @home-assistant/supervisor
/homeassistant/components/arris_tg2492lg/ @vanbalken /homeassistant/components/arris_tg2492lg/ @vanbalken
/homeassistant/components/aseko_pool_live/ @milanmeu /homeassistant/components/aseko_pool_live/ @milanmeu
/tests/components/aseko_pool_live/ @milanmeu /tests/components/aseko_pool_live/ @milanmeu
/homeassistant/components/assist_pipeline/ @balloob @synesthesiam
/tests/components/assist_pipeline/ @balloob @synesthesiam
/homeassistant/components/asuswrt/ @kennedyshead @ollo69 /homeassistant/components/asuswrt/ @kennedyshead @ollo69
/tests/components/asuswrt/ @kennedyshead @ollo69 /tests/components/asuswrt/ @kennedyshead @ollo69
/homeassistant/components/atag/ @MatsNL /homeassistant/components/atag/ @MatsNL
@ -1312,8 +1314,6 @@ build.json @home-assistant/supervisor
/tests/components/vizio/ @raman325 /tests/components/vizio/ @raman325
/homeassistant/components/vlc_telnet/ @rodripf @MartinHjelmare /homeassistant/components/vlc_telnet/ @rodripf @MartinHjelmare
/tests/components/vlc_telnet/ @rodripf @MartinHjelmare /tests/components/vlc_telnet/ @rodripf @MartinHjelmare
/homeassistant/components/voice_assistant/ @balloob @synesthesiam
/tests/components/voice_assistant/ @balloob @synesthesiam
/homeassistant/components/voip/ @balloob @synesthesiam /homeassistant/components/voip/ @balloob @synesthesiam
/tests/components/voip/ @balloob @synesthesiam /tests/components/voip/ @balloob @synesthesiam
/homeassistant/components/volumio/ @OnFreund /homeassistant/components/volumio/ @OnFreund

View File

@ -1,4 +1,4 @@
"""The Voice Assistant integration.""" """The Assist pipeline integration."""
from __future__ import annotations from __future__ import annotations
from collections.abc import AsyncIterable from collections.abc import AsyncIterable
@ -33,7 +33,7 @@ __all__ = (
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
"""Set up Voice Assistant integration.""" """Set up the Assist pipeline integration."""
await async_setup_pipeline_store(hass) await async_setup_pipeline_store(hass)
async_register_websocket_api(hass) async_register_websocket_api(hass)

View File

@ -0,0 +1,2 @@
"""Constants for the Assist pipeline integration."""
DOMAIN = "assist_pipeline"

View File

@ -1,4 +1,4 @@
"""Voice Assistant errors.""" """Assist pipeline errors."""
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError

View File

@ -1,9 +1,9 @@
{ {
"domain": "voice_assistant", "domain": "assist_pipeline",
"name": "Voice Assistant", "name": "Assist pipeline",
"codeowners": ["@balloob", "@synesthesiam"], "codeowners": ["@balloob", "@synesthesiam"],
"dependencies": ["conversation", "stt", "tts"], "dependencies": ["conversation", "stt", "tts"],
"documentation": "https://www.home-assistant.io/integrations/voice_assistant", "documentation": "https://www.home-assistant.io/integrations/assist_pipeline",
"iot_class": "local_push", "iot_class": "local_push",
"quality_scale": "internal", "quality_scale": "internal",
"requirements": ["webrtcvad==2.0.10"] "requirements": ["webrtcvad==2.0.10"]

View File

@ -1,4 +1,4 @@
"""Voice Assistant Websocket API.""" """Assist pipeline Websocket API."""
import asyncio import asyncio
import audioop # pylint: disable=deprecated-module import audioop # pylint: disable=deprecated-module
from collections.abc import Callable from collections.abc import Callable
@ -33,12 +33,12 @@ def async_register_websocket_api(hass: HomeAssistant) -> None:
"""Register the websocket API.""" """Register the websocket API."""
websocket_api.async_register_command( websocket_api.async_register_command(
hass, hass,
"voice_assistant/run", "assist_pipeline/run",
websocket_run, websocket_run,
vol.All( vol.All(
websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend( websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend(
{ {
vol.Required("type"): "voice_assistant/run", vol.Required("type"): "assist_pipeline/run",
# pylint: disable-next=unnecessary-lambda # pylint: disable-next=unnecessary-lambda
vol.Required("start_stage"): lambda val: PipelineStage(val), vol.Required("start_stage"): lambda val: PipelineStage(val),
# pylint: disable-next=unnecessary-lambda # pylint: disable-next=unnecessary-lambda

View File

@ -1,2 +0,0 @@
"""Constants for the Voice Assistant integration."""
DOMAIN = "voice_assistant"

View File

@ -3,7 +3,7 @@
"name": "Voice over IP", "name": "Voice over IP",
"codeowners": ["@balloob", "@synesthesiam"], "codeowners": ["@balloob", "@synesthesiam"],
"config_flow": true, "config_flow": true,
"dependencies": ["voice_assistant"], "dependencies": ["assist_pipeline"],
"documentation": "https://www.home-assistant.io/integrations/voip", "documentation": "https://www.home-assistant.io/integrations/voip",
"iot_class": "local_push", "iot_class": "local_push",
"quality_scale": "internal", "quality_scale": "internal",

View File

@ -10,13 +10,13 @@ import async_timeout
from voip_utils import CallInfo, RtpDatagramProtocol, SdpInfo, VoipDatagramProtocol from voip_utils import CallInfo, RtpDatagramProtocol, SdpInfo, VoipDatagramProtocol
from homeassistant.components import stt, tts from homeassistant.components import stt, tts
from homeassistant.components.voice_assistant import ( from homeassistant.components.assist_pipeline import (
Pipeline, Pipeline,
PipelineEvent, PipelineEvent,
PipelineEventType, PipelineEventType,
async_pipeline_from_audio_stream, async_pipeline_from_audio_stream,
) )
from homeassistant.components.voice_assistant.vad import VoiceCommandSegmenter from homeassistant.components.assist_pipeline.vad import VoiceCommandSegmenter
from homeassistant.const import __version__ from homeassistant.const import __version__
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant

View File

@ -398,6 +398,12 @@
"config_flow": true, "config_flow": true,
"iot_class": "cloud_polling" "iot_class": "cloud_polling"
}, },
"assist_pipeline": {
"name": "Assist pipeline",
"integration_type": "hub",
"config_flow": false,
"iot_class": "local_push"
},
"asterisk": { "asterisk": {
"name": "Asterisk", "name": "Asterisk",
"integrations": { "integrations": {
@ -6056,12 +6062,6 @@
} }
} }
}, },
"voice_assistant": {
"name": "Voice Assistant",
"integration_type": "hub",
"config_flow": false,
"iot_class": "local_push"
},
"voicerss": { "voicerss": {
"name": "VoiceRSS", "name": "VoiceRSS",
"integration_type": "hub", "integration_type": "hub",

View File

@ -2619,7 +2619,7 @@ waterfurnace==1.1.0
# homeassistant.components.cisco_webex_teams # homeassistant.components.cisco_webex_teams
webexteamssdk==1.1.1 webexteamssdk==1.1.1
# homeassistant.components.voice_assistant # homeassistant.components.assist_pipeline
webrtcvad==2.0.10 webrtcvad==2.0.10
# homeassistant.components.whirlpool # homeassistant.components.whirlpool

View File

@ -1880,7 +1880,7 @@ wallbox==0.4.12
# homeassistant.components.folder_watcher # homeassistant.components.folder_watcher
watchdog==2.3.1 watchdog==2.3.1
# homeassistant.components.voice_assistant # homeassistant.components.assist_pipeline
webrtcvad==2.0.10 webrtcvad==2.0.10
# homeassistant.components.whirlpool # homeassistant.components.whirlpool

View File

@ -136,4 +136,4 @@ async def init_components(
assert await async_setup_component(hass, tts.DOMAIN, {"tts": {"platform": "test"}}) assert await async_setup_component(hass, tts.DOMAIN, {"tts": {"platform": "test"}})
assert await async_setup_component(hass, stt.DOMAIN, {"stt": {"platform": "test"}}) assert await async_setup_component(hass, stt.DOMAIN, {"stt": {"platform": "test"}})
assert await async_setup_component(hass, "media_source", {}) assert await async_setup_component(hass, "media_source", {})
assert await async_setup_component(hass, "voice_assistant", {}) assert await async_setup_component(hass, "assist_pipeline", {})

View File

@ -2,7 +2,7 @@
from syrupy.assertion import SnapshotAssertion from syrupy.assertion import SnapshotAssertion
from homeassistant.components import stt, voice_assistant from homeassistant.components import assist_pipeline, stt
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -18,7 +18,7 @@ async def test_pipeline_from_audio_stream(
yield b"part2" yield b"part2"
yield b"" yield b""
await voice_assistant.async_pipeline_from_audio_stream( await assist_pipeline.async_pipeline_from_audio_stream(
hass, hass,
events.append, events.append,
stt.SpeechMetadata( stt.SpeechMetadata(

View File

@ -1,8 +1,8 @@
"""Websocket tests for Voice Assistant integration.""" """Websocket tests for Voice Assistant integration."""
from typing import Any from typing import Any
from homeassistant.components.voice_assistant.const import DOMAIN from homeassistant.components.assist_pipeline.const import DOMAIN
from homeassistant.components.voice_assistant.pipeline import ( from homeassistant.components.assist_pipeline.pipeline import (
STORAGE_KEY, STORAGE_KEY,
STORAGE_VERSION, STORAGE_VERSION,
PipelineStorageCollection, PipelineStorageCollection,
@ -67,7 +67,7 @@ async def test_loading_datasets_from_storage(
hass_storage[STORAGE_KEY] = { hass_storage[STORAGE_KEY] = {
"version": 1, "version": 1,
"minor_version": 1, "minor_version": 1,
"key": "voice_assistant.pipelines", "key": "assist_pipeline.pipelines",
"data": { "data": {
"items": [ "items": [
{ {
@ -98,7 +98,7 @@ async def test_loading_datasets_from_storage(
}, },
} }
assert await async_setup_component(hass, "voice_assistant", {}) assert await async_setup_component(hass, "assist_pipeline", {})
store: PipelineStorageCollection = hass.data[DOMAIN] store: PipelineStorageCollection = hass.data[DOMAIN]
assert len(store.data) == 3 assert len(store.data) == 3

View File

@ -1,7 +1,7 @@
"""Tests for webrtcvad voice command segmenter.""" """Tests for webrtcvad voice command segmenter."""
from unittest.mock import patch from unittest.mock import patch
from homeassistant.components.voice_assistant.vad import VoiceCommandSegmenter from homeassistant.components.assist_pipeline.vad import VoiceCommandSegmenter
_ONE_SECOND = 16000 * 2 # 16Khz 16-bit _ONE_SECOND = 16000 * 2 # 16Khz 16-bit

View File

@ -4,8 +4,8 @@ from unittest.mock import ANY, MagicMock, patch
from syrupy.assertion import SnapshotAssertion from syrupy.assertion import SnapshotAssertion
from homeassistant.components.voice_assistant.const import DOMAIN from homeassistant.components.assist_pipeline.const import DOMAIN
from homeassistant.components.voice_assistant.pipeline import ( from homeassistant.components.assist_pipeline.pipeline import (
Pipeline, Pipeline,
PipelineStorageCollection, PipelineStorageCollection,
) )
@ -25,7 +25,7 @@ async def test_text_only_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "intent", "start_stage": "intent",
"end_stage": "intent", "end_stage": "intent",
"input": {"text": "Are the lights on?"}, "input": {"text": "Are the lights on?"},
@ -67,7 +67,7 @@ async def test_audio_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "stt", "start_stage": "stt",
"end_stage": "tts", "end_stage": "tts",
"input": { "input": {
@ -139,7 +139,7 @@ async def test_intent_timeout(
): ):
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "intent", "start_stage": "intent",
"end_stage": "intent", "end_stage": "intent",
"input": {"text": "Are the lights on?"}, "input": {"text": "Are the lights on?"},
@ -180,12 +180,12 @@ async def test_text_pipeline_timeout(
await asyncio.sleep(3600) await asyncio.sleep(3600)
with patch( with patch(
"homeassistant.components.voice_assistant.pipeline.PipelineInput.execute", "homeassistant.components.assist_pipeline.pipeline.PipelineInput.execute",
new=sleepy_run, new=sleepy_run,
): ):
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "intent", "start_stage": "intent",
"end_stage": "intent", "end_stage": "intent",
"input": {"text": "Are the lights on?"}, "input": {"text": "Are the lights on?"},
@ -218,7 +218,7 @@ async def test_intent_failed(
): ):
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "intent", "start_stage": "intent",
"end_stage": "intent", "end_stage": "intent",
"input": {"text": "Are the lights on?"}, "input": {"text": "Are the lights on?"},
@ -258,12 +258,12 @@ async def test_audio_pipeline_timeout(
await asyncio.sleep(3600) await asyncio.sleep(3600)
with patch( with patch(
"homeassistant.components.voice_assistant.pipeline.PipelineInput.execute", "homeassistant.components.assist_pipeline.pipeline.PipelineInput.execute",
new=sleepy_run, new=sleepy_run,
): ):
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "stt", "start_stage": "stt",
"end_stage": "tts", "end_stage": "tts",
"input": { "input": {
@ -298,7 +298,7 @@ async def test_stt_provider_missing(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "stt", "start_stage": "stt",
"end_stage": "tts", "end_stage": "tts",
"input": { "input": {
@ -321,14 +321,14 @@ async def test_stt_stream_failed(
) -> None: ) -> None:
"""Test events from a pipeline run with a non-existent STT provider.""" """Test events from a pipeline run with a non-existent STT provider."""
with patch( with patch(
"tests.components.voice_assistant.conftest.MockSttProvider.async_process_audio_stream", "tests.components.assist_pipeline.conftest.MockSttProvider.async_process_audio_stream",
new=MagicMock(side_effect=RuntimeError), new=MagicMock(side_effect=RuntimeError),
): ):
client = await hass_ws_client(hass) client = await hass_ws_client(hass)
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "stt", "start_stage": "stt",
"end_stage": "tts", "end_stage": "tts",
"input": { "input": {
@ -376,7 +376,7 @@ async def test_tts_failed(
await client.send_json( await client.send_json(
{ {
"id": 5, "id": 5,
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "tts", "start_stage": "tts",
"end_stage": "tts", "end_stage": "tts",
"input": {"text": "Lights are on."}, "input": {"text": "Lights are on."},
@ -411,7 +411,7 @@ async def test_invalid_stage_order(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/run", "type": "assist_pipeline/run",
"start_stage": "tts", "start_stage": "tts",
"end_stage": "stt", "end_stage": "stt",
"input": {"text": "Lights are on."}, "input": {"text": "Lights are on."},
@ -432,7 +432,7 @@ async def test_add_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/pipeline/create", "type": "assist_pipeline/pipeline/create",
"conversation_engine": "test_conversation_engine", "conversation_engine": "test_conversation_engine",
"language": "test_language", "language": "test_language",
"name": "test_name", "name": "test_name",
@ -472,7 +472,7 @@ async def test_delete_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/pipeline/create", "type": "assist_pipeline/pipeline/create",
"conversation_engine": "test_conversation_engine", "conversation_engine": "test_conversation_engine",
"language": "test_language", "language": "test_language",
"name": "test_name", "name": "test_name",
@ -488,7 +488,7 @@ async def test_delete_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/pipeline/delete", "type": "assist_pipeline/pipeline/delete",
"pipeline_id": pipeline_id, "pipeline_id": pipeline_id,
} }
) )
@ -498,7 +498,7 @@ async def test_delete_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/pipeline/delete", "type": "assist_pipeline/pipeline/delete",
"pipeline_id": pipeline_id, "pipeline_id": pipeline_id,
} }
) )
@ -517,14 +517,14 @@ async def test_list_pipelines(
client = await hass_ws_client(hass) client = await hass_ws_client(hass)
pipeline_store: PipelineStorageCollection = hass.data[DOMAIN] pipeline_store: PipelineStorageCollection = hass.data[DOMAIN]
await client.send_json_auto_id({"type": "voice_assistant/pipeline/list"}) await client.send_json_auto_id({"type": "assist_pipeline/pipeline/list"})
msg = await client.receive_json() msg = await client.receive_json()
assert msg["success"] assert msg["success"]
assert msg["result"] == [] assert msg["result"] == []
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/pipeline/create", "type": "assist_pipeline/pipeline/create",
"conversation_engine": "test_conversation_engine", "conversation_engine": "test_conversation_engine",
"language": "test_language", "language": "test_language",
"name": "test_name", "name": "test_name",
@ -536,7 +536,7 @@ async def test_list_pipelines(
assert msg["success"] assert msg["success"]
assert len(pipeline_store.data) == 1 assert len(pipeline_store.data) == 1
await client.send_json_auto_id({"type": "voice_assistant/pipeline/list"}) await client.send_json_auto_id({"type": "assist_pipeline/pipeline/list"})
msg = await client.receive_json() msg = await client.receive_json()
assert msg["success"] assert msg["success"]
assert msg["result"] == [ assert msg["result"] == [
@ -560,7 +560,7 @@ async def test_update_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/pipeline/update", "type": "assist_pipeline/pipeline/update",
"conversation_engine": "new_conversation_engine", "conversation_engine": "new_conversation_engine",
"language": "new_language", "language": "new_language",
"name": "new_name", "name": "new_name",
@ -578,7 +578,7 @@ async def test_update_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/pipeline/create", "type": "assist_pipeline/pipeline/create",
"conversation_engine": "test_conversation_engine", "conversation_engine": "test_conversation_engine",
"language": "test_language", "language": "test_language",
"name": "test_name", "name": "test_name",
@ -593,7 +593,7 @@ async def test_update_pipeline(
await client.send_json_auto_id( await client.send_json_auto_id(
{ {
"type": "voice_assistant/pipeline/update", "type": "assist_pipeline/pipeline/update",
"conversation_engine": "new_conversation_engine", "conversation_engine": "new_conversation_engine",
"language": "new_language", "language": "new_language",
"name": "new_name", "name": "new_name",

View File

@ -4,7 +4,7 @@ from unittest.mock import Mock, patch
import async_timeout import async_timeout
from homeassistant.components import voice_assistant, voip from homeassistant.components import assist_pipeline, voip
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.setup import async_setup_component from homeassistant.setup import async_setup_component
@ -35,7 +35,7 @@ async def test_pipeline(hass: HomeAssistant) -> None:
# Test empty data # Test empty data
event_callback( event_callback(
voice_assistant.PipelineEvent( assist_pipeline.PipelineEvent(
type="not-used", type="not-used",
data={}, data={},
) )
@ -43,8 +43,8 @@ async def test_pipeline(hass: HomeAssistant) -> None:
# Fake intent result # Fake intent result
event_callback( event_callback(
voice_assistant.PipelineEvent( assist_pipeline.PipelineEvent(
type=voice_assistant.PipelineEventType.INTENT_END, type=assist_pipeline.PipelineEventType.INTENT_END,
data={ data={
"intent_output": { "intent_output": {
"conversation_id": "fake-conversation", "conversation_id": "fake-conversation",
@ -55,8 +55,8 @@ async def test_pipeline(hass: HomeAssistant) -> None:
# Proceed with media output # Proceed with media output
event_callback( event_callback(
voice_assistant.PipelineEvent( assist_pipeline.PipelineEvent(
type=voice_assistant.PipelineEventType.TTS_END, type=assist_pipeline.PipelineEventType.TTS_END,
data={"tts_output": {"media_id": _MEDIA_ID}}, data={"tts_output": {"media_id": _MEDIA_ID}},
) )
) )