I am trying to integrate a niche TTS provider. I have the RestAPI working correctly, but it operates by responding with the and audio file. I don’t know exactly how to tell Home Assistant what to do with the file. I would just as soon have it play the audio file directly to a media player and not save the file, but if I need to save the file, that is fine too.
Here is what I currently have:
action: rest_command.fish_audio_tts
metadata: {}
data:
model: speech-1.5
model_reference_id: 5196af35f6ff4a0dbf541793fc9f2157
tts_text: This is the text I will be reading.
format: mp3
response_variable: api_request_response
How do I get that file to play to my media player?
how does the response look like (please donot add the whole encoded part of the file). The json-response could/should have a filename and often (?) a base64 representation of the file which you then need to decode and store before you can do anyhting with it. tbh I am not sure if HA has this built-in
That would have been my expectation. I would have know where to get started with that. When I ran the API via Postman, I saved the file directly from the UI. Here is the response I get when running from HA developer tools:
content: >-
the `Content-Type` requested by the client is not supported:
application/octet-stream
status: 415
And what if you add Content-type application/json to the header?
Here is the configuration I have for the Rest API. I actually had a typo and corrected it.
fish_audio_tts:
url: https://api.fish.audio/v1/tts
method: POST
headers:
Authorization: "Bearer <API key>"
model: "{{ model }}"
content-type: "application/json"
payload: '{"text":"{{ tts_text }}","reference_id":"{{ model_reference_id }}","format":"{{ format }}"}'
verify_ssl: true
Here is what I am seeing now:
Well, then I am stuck too, I donot know the fish thing and also no clue why HA would not accept octet-stream. Have you tried running this using curl as well (command-line integration)? I would start from the cli and see what works (if anything)
1 Like
I changed it to a curl command and it worked great. For anyone interested, here is the full config:
configuration.yml:
shell_command:
fish_audio_tts: |
curl -X POST
-H "Content-Type: application/json"
-H "model: {{ model }}"
-H "Authorization: Bearer <api key>"
-d '{"text":"{{ tts_text }}","reference_id":"{{ model_reference_id }}","format":"{{ format }}"}'
-o "/media/path/{{ filename }}"
https://api.fish.audio/v1/tts
script:
action: shell_command.fish_audio_tts
metadata: {}
data:
model: speech-1.5
model_reference_id: 5196af35f6ff4a0dbf541793fc9f2157
tts_text: This is the text I will be reading.
format: mp3
filename: filename.mp3
response_variable: api_request_response
Happy ideas worked…stil no clue what you do with it 