Send audio/mp3 to an established call ?
Closed this issue · 11 comments
As its possible to send DTMF digits to an established call, would it be possible to add sending audio/mp3 to an established call ?
something like :
service: hassio.addon_stdin
data_template:
addon: c7744bff_ha-sip
input:
command: play_audio ?
number: sip:**620@fritz.box
audio_file: '/config/www/call_forward.mp3'
I guess one could implement that. Would you like to try?
if you mean by try, to test a new command if implemented, yes :)
if you mean implementing command myself, I have no clue howto :/
I just released a new "next" version with some new features. You can see the diff of the README here: https://github.com/arnonym/ha-plugins/compare/next?expand=1#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5
Would be nice if you can test the changes 😄
I've just updated and tried a couple of times.
With an active call i tried in developer tools / service :
service: hassio.addon_stdin
data:
addon: 8cd50eef_ha-sip-next
input:
command: play_message
number: port_04
message: hello!
tts_language: en
And got a loud 'beep' and log shows :
| 14:02:20.801876 [1] Playing message: hello!
| 14:02:20.812143 [ ] Error getting tts file 500 b'500: Internal Server Error'
| 14:02:22.822202 [1] Playback done.
| 14:02:22.822293 [ ] Calling webhook sip_call_webhook_id with data {'event': 'playback_done', 'sip_account': 1, 'caller': '<sip:port_04@192.168.1.161>', 'parsed_caller': 'port_04', 'type': 'message', 'message': 'hello!'}
| 14:02:22.829652 [ ] Webhook response 200 b''
But this worked :
service: hassio.addon_stdin
data:
addon: 8cd50eef_ha-sip-next
input:
command: play_message
number: port_04
message: hello!
I get a correct single 'Hello', and spamming the 'call service' button results in , hello, hello, hello, so this works excellent :)
edit, ah...tts needs correct parameter tts_language: en-GB
works :)
service: hassio.addon_stdin
data:
addon: 8cd50eef_ha-sip-next
input:
command: play_audio_file
number: port_04
audio_file: '/config/www/authentic_80s_line_noise.mp3'
This works perfect :)
thank you for adding these commands..
im just curious, the tts.cloud_say
supports different voices :
service: tts.cloud_say
data:
cache: false
entity_id: media_player.living_room
message: this is a test
language: en-US
options:
voice: AmberNeural
for en-US
you have these voices available :
"en-US": [
"JennyNeural",
"AIGenerate1Neural",
"AIGenerate2Neural",
"AmberNeural",
"AnaNeural",
"AriaNeural",
"AshleyNeural",
"BrandonNeural",
"ChristopherNeural",
"CoraNeural",
"DavisNeural",
"ElizabethNeural",
"EricNeural",
"GuyNeural",
"JacobNeural",
"JaneNeural",
"JasonNeural",
"JennyMultilingualNeural",
"MichelleNeural",
"MonicaNeural",
"NancyNeural",
"RogerNeural",
"SaraNeural",
"SteffanNeural",
"TonyNeural",
],
but trying this in ha-sip, the voice: parameters isnt used, its the same 'default' voice
service: hassio.addon_stdin
data:
addon: 8cd50eef_ha-sip-next
input:
command: play_message
number: port_04
message: This is a test
tts_language: en-US
options:
voice: AmberNeural
Nice it's working so far!
Regarding the TTS options, ha-sip is using the REST endpoint to convert text to speach, but in the docs is no mention of options [1], so no idea if this is supported somehow.
Are you able to test the newly introduced webhooks also? If everything is working as designed, I would do a release with these changes.
yes, got playback_done: working
sip-1-incoming.yaml:
...
answer_after: 1 # time in seconds after the call is answered (optional, defaults to 0)
webhook_to_call: # web-hook IDs which you can listen on in your actions (additional to the global web-hook)
call_established: sip_call_established # can be all the same, or different
entered_menu: entered_menu_webhook_id
dtmf_digit: sip-get-dtmf-digit
call_disconnected: sip_call_disconnected
playback_done: sip_playback_done
ring_timeout: sip_ring_timeout
i get the new event in logs :
| 16:47:20.818497 [1] Calling additional webhook sip_playback_done for event playback_done
but I couldn't get ring_timeout to work, or I dont see it triggered in the logs..
If I call and just leave it calling and after 60 seconds :
| 16:48:06.651390 [ ] Calling webhook sip_call_webhook_id with data {'event': 'ring_timeout', 'caller': 'sip:port_01@192.168.1.160:5060', 'parsed_caller': 'port_01', 'sip_account': 1}
| 16:48:06.659071 [ ] Webhook response 200 b''
| 16:48:06.659240 [1] Ring timeout of 60.0 triggered
| 16:48:06.659280 [1] Hang-up.
| 16:48:06.659425 [1] Call disconnected
| 16:48:06.659464 [1] Calling additional webhook sip_call_disconnected for event call_disconnected
I would assume there should be a
Calling additional webhook sip_ring_timeout for event ring_timeout
in the log
I just tried the ring_timeout one myself, and the webhook was called.
I called a number with:
command: dial
number: sip:**123@fritz.box
ring_timeout: 3
webhook_to_call:
ring_timeout: ring_timeout
and received the log message:
[1] Calling additional webhook ring_timeout for event ring_timeout
Not sure what you've done differently?
ah...my bad, it works...i needed to add the new webhook to the automation that does the calling..
service: hassio.addon_stdin
data:
addon: 8cd50eef_ha-sip-next
input:
command: dial
number: sip:port_01@192.168.1.160:5060
ring_timeout: 60
sip_account: 1
webhook_to_call:
call_established: sip_connect_call_bridge_01
call_disconnected: sip_call_disconnected
ring_timeout: sip_ring_timeout
| 17:32:14.975989 [1] Registering call with id sip:port_01@192.168.1.160:5060
| 17:32:14.976038 [ ] Add to state: sip:port_01@192.168.1.160:5060
| 17:32:14.980816 [1] Calling
| 17:32:15.040868 [1] Early
| 17:33:14.986412 [1] Calling additional webhook sip_ring_timeout for event ring_timeout
I added it to the sip-1-incoming.yaml
...and it didnt trigger from there
This is great, I can add a mp3 playback to play when nobody picks up....or a tts message :) many possibilities now, love it...
Thanks for testing!