Closed dbullendsl closed 11 months ago
Hi @dbullendsl. I'm sorry to hear you're having issues.
Thank you for the detailed log and the list of your troubleshooting steps!
I think that your issue might be due to an incorrect public mp3 folder path in the integration's configuration. Can you please check that the public mp3 folder path is a full path and not relative?
You can access the integration's configuration by navigating to Settings
--> Devices & services
--> Chime TTS
--> CONFIGURE
I thought of that too and did change it at one time to /homeassistant/www/chime_tts I also changed it to /local/chime_tts but that didn't change anything either.
If I manually create the /www/chime_tts folder and drop a known good mp3 into it I can reference it from the outside with a browser.
I've set things back to the default and here's a screen shot. ''' ''' I also noticed that even though the chime_tts.play function isn't expected to run with Amazon devices that it also doesn't produce any mp3 output.
As I’m not familiar with your setup I can’t know what are the correct paths are but I still think that the lack of mp3 files is due to an issue with the paths, probably for both the service calls.
Note that the MP3s generated from the chime_tts.say
service only persist if the cache parameter is set to true.
ok, I'll check that
I think I found the problem, by executing the chime_tts:say_url function in the developer's console I get a return result of
url: https://[server.url]/local/chime_tts/zfijllg7.mp3
but I think the result should be https://[server.url]/www/chime_tts/zfijllg7.mp3
Elsewhere in comments in other issues there were instructions to make sure that /local pointed to /media, but that's not a public path for web connections. From running the chime_tts:say fuction with the cache parameter set to true results from the TTS service end up in /media/sounds/temp/chime_tts which is the same as /local/sounds/temp/chime_tts and is not accessible externally. Your code should then move the result to /homeassistant/www/chime_tts which would be accessible as https://[server.url]/www/chime_tts/tts_file.mp3
You described exactly what the code does (chime_tts.say
saves to media
and chime_tts.say_url
saves to www
).
In Home Assistant the www
folder is accessible publicly as https://[server.url]/local/ so the URL from your last comment is correct. The issue is that the file is not being saved in the right folder, and therefore cannot be found at that address.
I can confirm that it works correctly in both my docker development environment and my HAOS Raspberry Pi 4 production environment.
It is for these reasons that I feel the problem lies in the public mp3 folder path defined in your configuration.
Could you please try setting the public mp3 folder path to: /config/www/chime_tts
?
Excellent! That was it.
the intigration is working and I'm getting the mp3 in the www/chime_tts folder, and can paste the URL into a browser and it'll play.
Amazon is still throwing an error but I've seen that before when the audio file didn't match Amazon's specifications, so it's not a problem with the integration.
If you've got any suggestions on fixing that I'd appreciate it. Can the options field be used to do anything like calling ffmpeg to format the output?
I’m glad it is now working for you!
I would be happy to add support for encoding with ffmpeg. I can add a checkbox specifically for Amazon’s requirements and also a text field to pass ffmpeg parameters for other use cases.
That would be great, meanwhile I do have it working using a shell command to ffmpeg with the parameters specified on Amazon's AWS SML page. I'll post everything here soon.
here's my solution, not completely refined, but it works. It consists of 3 parts, 2 scripts and a shell command.
The set up looks like this:
Edit configuration.yaml to add the following
# Add ffmpeg to the configuration to format audio
# output to play on Amazon Echos
ffmpeg:
shell_command:
amazon_level_up: ffmpeg -i '{{input_url}}' -y -ac 2 -codec:a libmp3lame -b:a 48k -ar 16000 -write_xing 0 '{{output_url}}'
the first script calls chime_tts.say_url, then sends the output to the shell command with another script
alias: aa chime
sequence:
- service: chime_tts.say_url
data:
chime_path: bells
end_chime_path: bells 2
delay: 0
final_delay: 0
tts_playback_speed: 100
message: "{{message}}"
tts_platform: google_translate
cache: false
response_variable: chime_tts
- service: script.aa_ffmpeg_convert
data:
input_url: "{{chime_tts.url}}"
output_url: /config/www/chime_tts/output.mp3
- service: notify.alexa_media
data:
message: |
<audio src="https://[your_server.url]/local/chime_tts/output.mp3"/>
target:
- media_player.office_echo_dot
data:
type: tts
mode: single
fields:
message:
selector:
text: null
name: message
second script:
alias: aa ffmpeg_convert
sequence:
- service: shell_command.amazon_level_up
data:
input_url: "{{input_url}}"
output_url: "{{output_url}}"
mode: single
fields:
input_url:
selector:
text: null
name: input_url
required: true
output_url:
selector:
text: null
name: output_url
required: true
I probably could have gotten by with one script, but I decided to split out the ffmpeg part in case I needed it for some other use case when sending audio to amazon echoes.
the only variables are the input message and the resultant url supplied by chime_tts.say_url, the output.mp3 from the shell command is overwritten each time it's run so is a fixed name. I'll be changing the inputs so that I can supply the sounds to play before / after the announcements. Haven't tried changing the voice yet, but for now this is it.
Thanks for the assistance, great idea.
Hey @dbullendsl, I added a new FFmpeg Arguments
parameter to the chime_tts.say
and chime_tts.say_url
services, allowing you to list the conversion parameters you want to use for an FFmpeg conversion on the generated audio:
I created a discussion here, and it would be great if you could please test it out and let me know if it works for your use case.
I created a new beta version with the changes. Please follow these steps to install it:
⋮
button in the top right↻ Redownload
optionShow beta versions
optionv0.10.2-beta1
from the updated version drop-down list
Checklist
Is your feature request related to a problem? Please describe.
using the say_url function doesn't appear to work. I only have access to Amazon echos and only get an output that says "sorry can't access your simon says..."
First I'm running HassOS on an Intel mini PC
Here's what I'm doing. Execute a script that takes an input for the message and calls the chime_tts:say_url service then sends the output to the echos:
Here's the script and trace.
and here's the log:
so far what I've done
I ssh into the server and found there is no folder /www/chime_tts, I've tried directly accessing the URL on the server and get a 404 error I manually created the /www/chime_tts folder and nothing is written there I looked for any new mp3s that were created and found none.
Describe the solution you'd like
locate the issues
Describe alternatives you've considered
stick with my existing solutions
Additional context
none