openai_tts icon indicating copy to clipboard operation
openai_tts copied to clipboard

Added a configuration but no audio

Open junalmeida opened this issue 1 year ago • 2 comments
trafficstars

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.

junalmeida avatar Jun 19 '24 14:06 junalmeida

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

sfortis avatar Jun 20 '24 06:06 sfortis

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.

Flight777 avatar Jul 15 '24 19:07 Flight777

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.

dai80027 avatar Jan 10 '25 22:01 dai80027

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 avatar Feb 09 '25 04:02 joestump

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.

joestump avatar Feb 09 '25 05:02 joestump

In both my dev and normal home environments, I've never seen a FLAC file entered through the TTS proxy. Check the latest release, though.

If you enable debugging in voice assistants, in the end, you should see something like this:

 tts_output:
    media_id: >-
      media-source://tts/tts.openai_tts_shimmer?message=Hello
    url: /api/tts_proxy/iCqU34DjyOwvaQEMNCaKHg.mp3
    mime_type: audio/mpeg

sfortis avatar Mar 14 '25 15:03 sfortis