mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 02:38:10 +02:00
Remove media_id from pipeline TTS-END events
This commit is contained in:
@ -20,9 +20,6 @@ import hass_nabucasa
|
|||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components import conversation, stt, tts, wake_word, websocket_api
|
from homeassistant.components import conversation, stt, tts, wake_word, websocket_api
|
||||||
from homeassistant.components.tts import (
|
|
||||||
generate_media_source_id as tts_generate_media_source_id,
|
|
||||||
)
|
|
||||||
from homeassistant.const import ATTR_SUPPORTED_FEATURES, MATCH_ALL
|
from homeassistant.const import ATTR_SUPPORTED_FEATURES, MATCH_ALL
|
||||||
from homeassistant.core import Context, HomeAssistant, callback
|
from homeassistant.core import Context, HomeAssistant, callback
|
||||||
from homeassistant.exceptions import HomeAssistantError
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
@ -1276,33 +1273,19 @@ class PipelineRun:
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
|
||||||
# Synthesize audio and get URL
|
|
||||||
tts_media_id = tts_generate_media_source_id(
|
|
||||||
self.hass,
|
|
||||||
tts_input,
|
|
||||||
engine=self.tts_stream.engine,
|
|
||||||
language=self.tts_stream.language,
|
|
||||||
options=self.tts_stream.options,
|
|
||||||
)
|
|
||||||
except Exception as src_error:
|
|
||||||
_LOGGER.exception("Unexpected error during text-to-speech")
|
|
||||||
raise TextToSpeechError(
|
|
||||||
code="tts-failed",
|
|
||||||
message="Unexpected error during text-to-speech",
|
|
||||||
) from src_error
|
|
||||||
|
|
||||||
self.tts_stream.async_set_message(tts_input)
|
self.tts_stream.async_set_message(tts_input)
|
||||||
|
|
||||||
tts_output = {
|
|
||||||
"media_id": tts_media_id,
|
|
||||||
"token": self.tts_stream.token,
|
|
||||||
"url": self.tts_stream.url,
|
|
||||||
"mime_type": self.tts_stream.content_type,
|
|
||||||
}
|
|
||||||
|
|
||||||
self.process_event(
|
self.process_event(
|
||||||
PipelineEvent(PipelineEventType.TTS_END, {"tts_output": tts_output})
|
PipelineEvent(
|
||||||
|
PipelineEventType.TTS_END,
|
||||||
|
{
|
||||||
|
"tts_output": {
|
||||||
|
"token": self.tts_stream.token,
|
||||||
|
"url": self.tts_stream.url,
|
||||||
|
"mime_type": self.tts_stream.content_type,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def _capture_chunk(self, audio_bytes: bytes | None) -> None:
|
def _capture_chunk(self, audio_bytes: bytes | None) -> None:
|
||||||
|
@ -84,7 +84,6 @@
|
|||||||
dict({
|
dict({
|
||||||
'data': dict({
|
'data': dict({
|
||||||
'tts_output': dict({
|
'tts_output': dict({
|
||||||
'media_id': "media-source://tts/test?message=Sorry,+I+couldn't+understand+that&language=en-US&tts_options=%7B%22voice%22:%22james_earl_jones%22%7D",
|
|
||||||
'mime_type': 'audio/mpeg',
|
'mime_type': 'audio/mpeg',
|
||||||
'token': 'test_token.mp3',
|
'token': 'test_token.mp3',
|
||||||
'url': '/api/tts_proxy/test_token.mp3',
|
'url': '/api/tts_proxy/test_token.mp3',
|
||||||
@ -183,7 +182,6 @@
|
|||||||
dict({
|
dict({
|
||||||
'data': dict({
|
'data': dict({
|
||||||
'tts_output': dict({
|
'tts_output': dict({
|
||||||
'media_id': "media-source://tts/test?message=Sorry,+I+couldn't+understand+that&language=en-US&tts_options=%7B%22voice%22:%22Arnold+Schwarzenegger%22%7D",
|
|
||||||
'mime_type': 'audio/mpeg',
|
'mime_type': 'audio/mpeg',
|
||||||
'token': 'test_token.mp3',
|
'token': 'test_token.mp3',
|
||||||
'url': '/api/tts_proxy/test_token.mp3',
|
'url': '/api/tts_proxy/test_token.mp3',
|
||||||
@ -282,7 +280,6 @@
|
|||||||
dict({
|
dict({
|
||||||
'data': dict({
|
'data': dict({
|
||||||
'tts_output': dict({
|
'tts_output': dict({
|
||||||
'media_id': "media-source://tts/test?message=Sorry,+I+couldn't+understand+that&language=en-US&tts_options=%7B%22voice%22:%22Arnold+Schwarzenegger%22%7D",
|
|
||||||
'mime_type': 'audio/mpeg',
|
'mime_type': 'audio/mpeg',
|
||||||
'token': 'test_token.mp3',
|
'token': 'test_token.mp3',
|
||||||
'url': '/api/tts_proxy/test_token.mp3',
|
'url': '/api/tts_proxy/test_token.mp3',
|
||||||
@ -405,7 +402,6 @@
|
|||||||
dict({
|
dict({
|
||||||
'data': dict({
|
'data': dict({
|
||||||
'tts_output': dict({
|
'tts_output': dict({
|
||||||
'media_id': "media-source://tts/test?message=Sorry,+I+couldn't+understand+that&language=en-US&tts_options=%7B%22voice%22:%22james_earl_jones%22%7D",
|
|
||||||
'mime_type': 'audio/mpeg',
|
'mime_type': 'audio/mpeg',
|
||||||
'token': 'test_token.mp3',
|
'token': 'test_token.mp3',
|
||||||
'url': '/api/tts_proxy/test_token.mp3',
|
'url': '/api/tts_proxy/test_token.mp3',
|
||||||
|
@ -80,7 +80,6 @@
|
|||||||
# name: test_audio_pipeline.6
|
# name: test_audio_pipeline.6
|
||||||
dict({
|
dict({
|
||||||
'tts_output': dict({
|
'tts_output': dict({
|
||||||
'media_id': "media-source://tts/test?message=Sorry,+I+couldn't+understand+that&language=en-US&tts_options=%7B%22voice%22:%22james_earl_jones%22%7D",
|
|
||||||
'mime_type': 'audio/mpeg',
|
'mime_type': 'audio/mpeg',
|
||||||
'token': 'test_token.mp3',
|
'token': 'test_token.mp3',
|
||||||
'url': '/api/tts_proxy/test_token.mp3',
|
'url': '/api/tts_proxy/test_token.mp3',
|
||||||
@ -171,7 +170,6 @@
|
|||||||
# name: test_audio_pipeline_debug.6
|
# name: test_audio_pipeline_debug.6
|
||||||
dict({
|
dict({
|
||||||
'tts_output': dict({
|
'tts_output': dict({
|
||||||
'media_id': "media-source://tts/test?message=Sorry,+I+couldn't+understand+that&language=en-US&tts_options=%7B%22voice%22:%22james_earl_jones%22%7D",
|
|
||||||
'mime_type': 'audio/mpeg',
|
'mime_type': 'audio/mpeg',
|
||||||
'token': 'test_token.mp3',
|
'token': 'test_token.mp3',
|
||||||
'url': '/api/tts_proxy/test_token.mp3',
|
'url': '/api/tts_proxy/test_token.mp3',
|
||||||
@ -274,7 +272,6 @@
|
|||||||
# name: test_audio_pipeline_with_enhancements.6
|
# name: test_audio_pipeline_with_enhancements.6
|
||||||
dict({
|
dict({
|
||||||
'tts_output': dict({
|
'tts_output': dict({
|
||||||
'media_id': "media-source://tts/test?message=Sorry,+I+couldn't+understand+that&language=en-US&tts_options=%7B%22voice%22:%22james_earl_jones%22%7D",
|
|
||||||
'mime_type': 'audio/mpeg',
|
'mime_type': 'audio/mpeg',
|
||||||
'token': 'test_token.mp3',
|
'token': 'test_token.mp3',
|
||||||
'url': '/api/tts_proxy/test_token.mp3',
|
'url': '/api/tts_proxy/test_token.mp3',
|
||||||
@ -387,7 +384,6 @@
|
|||||||
# name: test_audio_pipeline_with_wake_word_no_timeout.8
|
# name: test_audio_pipeline_with_wake_word_no_timeout.8
|
||||||
dict({
|
dict({
|
||||||
'tts_output': dict({
|
'tts_output': dict({
|
||||||
'media_id': "media-source://tts/test?message=Sorry,+I+couldn't+understand+that&language=en-US&tts_options=%7B%22voice%22:%22james_earl_jones%22%7D",
|
|
||||||
'mime_type': 'audio/mpeg',
|
'mime_type': 'audio/mpeg',
|
||||||
'token': 'test_token.mp3',
|
'token': 'test_token.mp3',
|
||||||
'url': '/api/tts_proxy/test_token.mp3',
|
'url': '/api/tts_proxy/test_token.mp3',
|
||||||
|
Reference in New Issue
Block a user