Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a configuration but no audio #15

Open
junalmeida opened this issue Jun 19, 2024 · 5 comments
Open

Added a configuration but no audio #15

junalmeida opened this issue Jun 19, 2024 · 5 comments

Comments

@junalmeida
Copy link

I've added a configuration as per instructions, but I can't hear any audio. Is there any setting missing?

Here is what it looks like:
The device:
image

The service call:

service: tts.speak
data:
  cache: true
  media_player_entity_id: media_player.vlc_telnet
  message: Test
target:
  entity_id: tts.openai_tts_nova

When I run it, I hear nothing, but UI shows as it succeeded.

This is the only log I can say it may be related to this, but I'm not 100% sure, because it is related to tags and this shouldn't stop it from playing.

2024-06-19 09:09:58.141 ERROR (MainThread) [homeassistant.components.tts] ID3 tag error: can't sync to MPEG frame

The media_player seems to be working normally, as I can use other tts services (like google translator google_say service) and I can hear it.

Thanks for your help.

@sfortis
Copy link
Owner

sfortis commented Jun 20, 2024

That's strange. I've connected my VLC (Windows, 3.0.20) using the Telnet interface and the integration works fine.

Integration provides just a plain MP3 file with TTS content. Check your /config/tts folder, and normally you'll find the cached MP3 file there from the TTS engine. Can you play it?

image

@Flight777
Copy link

Same issue for me, can't get it to work. I see the MP3, but only very small file size and when I try to play VLC says it's corrupted.

@dai80027
Copy link

I think I'm seeing the same problem. I see this in the log file:

Logger: aiohttp.server
Source: /usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py:451
First occurred: 3:06:26 PM (2 occurrences)
Last logged: 3:11:21 PM

Error handling request
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_protocol.py", line 480, in _handle_request
resp = await request_handler(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_app.py", line 569, in _handle
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/aiohttp/web_middlewares.py", line 117, in impl
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 86, in ban_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
return await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
response = await handler(request)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
result = await handler(request, **request.match_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/tts/init.py", line 1099, in get
content, data = await self.tts.async_read_tts(filename)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/tts/init.py", line 953, in async_read_tts
await pending
File "/usr/src/homeassistant/homeassistant/components/tts/init.py", line 806, in get_tts_data
data = await async_convert_audio(
^^^^^^^^^^^^^^^^^^^^^^^^^^
...<7 lines>...
)
^
File "/usr/src/homeassistant/homeassistant/components/tts/init.py", line 227, in async_convert_audio
return await hass.async_add_executor_job(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...<9 lines>...
)
^
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 59, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/tts/init.py", line 228, in
lambda: _convert_audio(
~~~~~~~~~~~~~~^
ffmpeg_manager.binary,
^^^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
to_sample_bytes=to_sample_bytes,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File "/usr/src/homeassistant/homeassistant/components/tts/init.py", line 292, in _convert_audio
raise RuntimeError(
...<2 lines>...
)
RuntimeError: Unexpected error while running ffmpeg with arguments: ['ffmpeg', '-y', '-f', 'wav', '-i', 'pipe:', '-f', 'mp3', '-q:a', '0', '/tmp/tmpdru86v3b.mp3'].See log for details.

@joestump
Copy link

joestump commented Feb 9, 2025

Not sure if this is related, but the new voice assistant doesn't work with this. The "Test" in the browser works fine, but when I set the voice assistant to use this I get no audio.

Seeing this exception in the HASS logs:

Error doing job: Exception in callback SpeechManager._async_get_tts_audio.<locals>.handle_error() at /usr/src/homeassistant/homeassistant/components/tts/__init__.py:844 (None)

Traceback (most recent call last):
  File "/usr/local/lib/python3.13/asyncio/events.py", line 89, in _run
    self._context.run(self._callback, *self._args)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 846, in handle_error
    if audio_task.exception():
       ~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 786, in get_tts_data
    extension, data = await engine_instance.internal_async_get_tts_audio(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        message, language, options
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 492, in internal_async_get_tts_audio
    return await self.async_get_tts_audio(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        message=message, language=language, options=options
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/components/tts/__init__.py", line 509, in async_get_tts_audio
    return await self.hass.async_add_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        partial(self.get_tts_audio, message, language, options=options)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
asyncio.exceptions.CancelledError

@joestump
Copy link

joestump commented Feb 9, 2025

I think I figured out my issue from

  tts_output:
    media_id: >-
      media-source://tts/tts.openai_tts_shimmer?message=Yes,+I+can+hear+you.&language=en&tts_options=%7B%22preferred_format%22:%22flac%22,%22preferred_sample_rate%22:48000,%22preferred_sample_channels%22:1,%22preferred_sample_bytes%22:2%7D
    url: /api/tts_proxy/hI-ISQ9cv_qmlWRy4JWUfA.flac
    mime_type: audio/flac

Note the mime_type and preferred_format are flac, but it looks like openai_tts is hard-coded to wav.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants