arnonym / ha-plugins

Home-Assistant SIP Gateway
Apache License 2.0
157 stars 19 forks source link

Error playing TTS #107

Closed Dtrieb closed 1 month ago

Dtrieb commented 1 month ago
service: hassio.addon_stdin
data:
    addon: c7744bff_ha-sip
    input:
        command: play_message
        number: sip:**610@fritz.box
        message: hello!
        tts_language: en

I try to send it but I get this error:

| 21:18:00.394084 [1] Playing message: hello!
| 21:18:00.419464 [ ] Error getting tts file 500 b'500: Internal Server Error'
21:18:00.420            pjsua_aud.c !Creating file player: /ha-sip/sound/answer.wav..
21:18:00.420           wav_player.c  .File player '/ha-sip/sound/answer.wav' created: samp.rate=44100, ch=1, bufsize=4KB, filesize=176KB
21:18:00.420            pjsua_aud.c  .Player created, id=1, slot=3
21:18:00.420            pjsua_aud.c  Conf connect: 3 --> 1
21:18:00.420           conference.c  .Port 3 (/ha-sip/sound/answer.wav) transmitting to port 1 (sip:**610@fritz.box)
| 21:18:02.431992 [1] Playback done.
arnonym commented 1 month ago

This is happening if the TTS service [1] is not correctly configured. You can also check the logs for a more specific error. Some TTS engines need the tts_language also in the format en-US. It's complicated.

[1] https://www.home-assistant.io/integrations/tts/

Dtrieb commented 1 month ago

I try also de-de but didn't work for me. Change the tts to picotss, also didn't work.

Any idea what I can do?

And is there a chance that we can write german @arnonym on another place?

arnonym commented 1 month ago

Feel free to write in german here, if that's easier for you. Please take a look into the home-assistant logs, if there pops anything up about your TTS problems. The easiest TTS service to test with is probably google, if you want to take a try with that one.

arnonym commented 1 month ago

You can also test TTS independent of ha-sip. Go to "media" in the main menu and then "Text to speach". There you can select the installed TTS engines and "say" some things.

Dtrieb commented 1 month ago

You can also test TTS independent of ha-sip. Go to "media" in the main menu and then "Text to speach". There you can select the installed TTS engines and "say" some things.

That works without any problems. (google_translate as TTS)

arnonym commented 1 month ago

Can you please post the tts part of the ha-sip log?

Dtrieb commented 1 month ago

Can you please post the tts part of the ha-sip log?

| 19:59:04.034776 [1] onCallMediaState call info state 5
| 19:59:04.035009 [1] Connected media 1
19:59:04.668       strm0x7fb8569098 !VAD re-enabled
| 19:59:05.034624 [1] Call is established.
| 19:59:05.034921 [ ] Calling webhook sip_call_webhook_id with data {'event': 'call_established', 'caller': 'sip:**621@fritz.box', 'parsed_caller': '**621', 'sip_account': 1}
| 19:59:05.068402 [ ] Webhook response 200 b''
| 19:59:05.068943 [1] No action supplied
| 19:59:05.069247 [1] Scheduled post action: noop
| 19:59:08.338567 [1] Playing message: hello!
| 19:59:08.364533 [ ] Error getting tts file 500 b'500: Internal Server Error'
19:59:08.366            pjsua_aud.c !Creating file player: /ha-sip/sound/answer.wav..
19:59:08.369           wav_player.c  .File player '/ha-sip/sound/answer.wav' created: samp.rate=44100, ch=1, bufsize=4KB, filesize=176KB
19:59:08.369            pjsua_aud.c  .Player created, id=0, slot=2
19:59:08.369            pjsua_aud.c  Conf connect: 2 --> 1
19:59:08.369           conference.c  .Port 2 (/ha-sip/sound/answer.wav) transmitting to port 1 (sip:**621@fritz.box)
| 19:59:10.388506 [1] Playback done.
| 19:59:10.388795 [ ] Calling webhook sip_call_webhook_id with data {'event': 'playback_done', 'sip_account': 1, 'caller': 'sip:**621@fritz.box', 'parsed_caller': '**621', 'type': 'message', 'message': 'hello!'}
| 19:59:10.413861 [ ] Webhook response 200 b''
arnonym commented 1 month ago

How does the TTS part of your ha-sip config looks like?

Dtrieb commented 1 month ago

How does the TTS part of your ha-sip config looks like?

platform: google_translate language: de

arnonym commented 1 month ago

Ich bin ein wenig ratlos. Can you check if there is anything logged in the home-assistant core logs?

Dtrieb commented 1 month ago
Logger: homeassistant.helpers.http
Quelle: helpers/http.py:134
Erstmals aufgetreten: 20. Mai 2024 um 20:02:42 (11 Vorkommnisse)
Zuletzt protokolliert: 19:59:08

Unable to serialize to JSON. Bad data found at $.error=Provider google_translate not found(<class 'homeassistant.exceptions.HomeAssistantError'>
Unable to serialize to JSON. Bad data found at $.error=Provider PicoTTS not found(<class 'homeassistant.exceptions.HomeAssistantError'>

und

Logger: homeassistant.components.tts
Quelle: components/tts/__init__.py:1014
Integration: Text-to-speech (TTS) (Dokumentation, Probleme)
Erstmals aufgetreten: 20. Mai 2024 um 20:02:42 (11 Vorkommnisse)
Zuletzt protokolliert: 19:59:08

Error on init tts: Provider google_translate not found
Error on init tts: Provider PicoTTS not found

Vielleicht hilft das?

arnonym commented 1 month ago

Can you post the tts configuration from your configuration.yaml?

Dtrieb commented 1 month ago

Da steht gar nichts drin wegen TTS.

Aber ich habe noch 2 Anmerkungen:

Wo finde ich genau und wird die die Datei direkt gelöscht? /ha-sip/sound/answer.wav

Ich höre anstatt der Nachricht einen Ton.

Und noch eine Frage:

Kannst du mir mal einen kompletten Code hier Posten mit dem ich alles zusammen ausführen/testen kann.

Dankeschön ☺️

arnonym commented 1 month ago

answer.wav is played if TTS conversion fails and it is part of ha-sip distribution.

I have

tts:
  - platform: google_translate

in my configuration.yaml. Not sure, if this is still the way to go, but you can try if it helps in your case.

Not sure what you mean with "complete" code? There are thousands of possibilities and use-cases.

Dtrieb commented 1 month ago

Juhu! Jetzt klappt es. 🎉👍

Mit kompletten Code meine ich:

Das ein Anruf gestartet wird und wenn abgenommen wird eine Nachricht angesagt wird. (Komplette Automation)

Bisher teste ich nämlich nur in den Entwicklerwerkzeuge unter Dienste.

arnonym commented 1 month ago
alias: "Klingel: Telefon bei Tasterdruck"
description: ""
trigger:
  - platform: state
    entity_id: binary_sensor.klingel
    from: "off"
    to: "on"
condition: []
action:
  - service: hassio.addon_stdin
    template:
      addon: c7744bff_ha-sip
      input:
        command: dial
        number: sip:**620@fritz.box
        menu:
          message: Es hat geklingelt
Dtrieb commented 1 month ago

Okay letzte Frage 😉 dann kannst du das hier auch zu machen:

Wenn ich in der Nachricht einen Wert (z.b. Temperatur von Thermometer nutzen will kann ich dann in der Nachricht einfach {{ states('sensor.xxx') }} eingeben?

arnonym commented 1 month ago

Never tried it myself, but this is just a standard home-assistant template, so this should work here like everywhere.

Dtrieb commented 1 month ago

Okay thanks for your help!