nimroddolev / chime_tts

A custom Home Assistant integration to play combined audio files before and/or after text-to-speech (TTS) messages
https://nimroddolev.github.io/chime_tts/
MIT License
196 stars 14 forks source link

Path for local media seems to use path name instead of virtual folder #52

Closed ErikApption closed 11 months ago

ErikApption commented 12 months ago

Checklist

Is your feature request related to a problem? Please describe.

This is my configuration

homeassistant:
  media_dirs:
    local: "/srv/homeassistant/media"
    sounds: "/home/homeassistant/media/sounds"

This is what chime_tts is trying to play

2023-12-03 01:09:43.144 DEBUG (MainThread) [custom_components.chime_tts] async_get_playback_audio_path
2023-12-03 01:09:43.144 DEBUG (MainThread) [custom_components.chime_tts] Attempting to retrieve generated mp3 file from cache
2023-12-03 01:09:43.144 DEBUG (MainThread) [custom_components.chime_tts]  - async_get_cached_audio_data('d1a2e30255739b81a89327b1d3adf66fb28f8631ffed391cb013e78e2ca774c4')
2023-12-03 01:09:43.144 DEBUG (MainThread) [custom_components.chime_tts]  - Retrieving key/value from chime_tts storage:
2023-12-03 01:09:43.144 DEBUG (MainThread) [custom_components.chime_tts]    - key: d1a2e30255739b81a89327b1d3adf66fb28f8631ffed391cb013e78e2ca774c4
2023-12-03 01:09:43.144 DEBUG (MainThread) [custom_components.chime_tts]    - value: {'audio_path': '/srv/homeassistant/srv/homeassistant/media/sounds/temp/chime_tts/k1liomfx.mp3', 'audio_duration': 7.778}
2023-12-03 01:09:43.145 DEBUG (MainThread) [custom_components.chime_tts]  - Cached audio data found
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts] Using previously generated mp3 saved in cache
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts]  - audio_dict = {'audio_path': '/srv/homeassistant/srv/homeassistant/media/sounds/temp/chime_tts/k1liomfx.mp3', 'audio_duration': 7.778}
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts]  - Setting 'media_player.bedroom' volume level to 1.0
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts]  - async_set_volume_level("media_player.bedroom", 1.0)
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts]  - Skipped setting volume
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts] Calling media_player.play_media service with data:
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts]  - media_content_type: music
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts]  - media_content_id: media-source://media_source/local/sounds/temp/chime_tts/k1liomfx.mp3
2023-12-03 01:09:43.146 DEBUG (MainThread) [custom_components.chime_tts]  - entity_id: ['media_player.bedroom']
2023-12-03 01:09:43.349 DEBUG (MainThread) [custom_components.chime_tts] ...media_player.play_media completed.
2023-12-03 01:09:43.349 DEBUG (MainThread) [custom_components.chime_tts] Waiting 7.778s for audio playback to complete...
2023-12-03 01:09:51.131 DEBUG (MainThread) [custom_components.chime_tts] Returning media_player.bedroom's volume level to 1.0
2023-12-03 01:09:51.131 DEBUG (MainThread) [custom_components.chime_tts]  - async_set_volume_level("media_player.bedroom", 1.0)
2023-12-03 01:09:51.131 DEBUG (MainThread) [custom_components.chime_tts]  - Skipped setting volume
2023-12-03 01:09:51.133 DEBUG (MainThread) [custom_components.chime_tts] Final URL = http://10.0.0.37:8123/srv/homeassistant/srv/homeassistant/media/sounds/temp/chime_tts/k1liomfx.mp3
2023-12-03 01:09:51.133 DEBUG (MainThread) [custom_components.chime_tts] ----- Chime TTS Say Completed in 7990.084000000001 ms -----
2023-12-03 01:09:51.134 DEBUG (MainThread) [custom_components.chime_tts] Removing current queued service call.
2023-12-03 01:09:51.134 DEBUG (MainThread) [custom_components.chime_tts] Queue emptied. Reinitializing values.

Describe the solution you'd like

Pretty sure the final url should be

http://10.0.0.37:8123/media/sounds/temp/chime_tts/k1liomfx.mp3

instead of

http://10.0.0.37:8123/srv/homeassistant/srv/homeassistant/media/sounds/temp/chime_tts/k1liomfx.mp3

Believe this was working in previous version

Describe alternatives you've considered

change media folders

Additional context

n/a

nimroddolev commented 12 months ago

Hi @ErikApption, sorry to hear you're having issues. You're correct: the link is incorrect.

In the debug logs you included, I see that in the service call to chime_tts.say_url has cache: true. Using the cache skips all the code which generates the mp3 file, so I can't see in the logs how the file was created initially. Could you please provide debug logs for a new service call to chime_tts.say_url where the cache parameter is disabled or set to false? Also, can you please make sure to include the full log?

Another place to check is the Chime TTS integration's configuration dialog: Settings --> Devices & services --> Chime TTS --> CONFIGURE

Please check that

  1. Media folder value is local and
  2. The Public mp3 folder path begins with /www/

chime_tts_options copy

ErikApption commented 11 months ago

Hi @nimroddolev

Thank you for looking into the issue! Ah I just discovered the settings page. It took me couple of attempts but I finally figured out the configuration. I'm still unclear what the public mp3 folder is. All the original mp3s are currently inside the custom_components that was installed with HACS.

I had not realized that temporary was a virtual path not a physical path. I know for HA OS installations, it looks the same but not on my core setup. my /media is /srv/homeassitant/media but chime_tts only needs the subfolder from local.

image

nimroddolev commented 11 months ago

My pleasure. I’m glad ad it’s working correctly for you 👍 In the latest release from today (v0.10.0) I added support for both relative and absolute paths. Feel free to let me know if you have any other issues or ideas for the future!