Help with MaryTTS and Sonos after 0.105.5 update

I upgraded from 0.104.3 to 0.105.5 yesterday, and today discovered that my MaryTTS announcements to my Sonos speaker are not working. I know that there were changes to MaryTTS in this release, but reading the docs, my config is fine. I’m running HA Supervised (formerly Hass.io) on an older NUC running Ubuntu 18.04, and have this MaryTTS image running in Docker: https://hub.docker.com/r/sliversniper/marytts (installed via the Portainer add-on). This is my MaryTTS config entry:

tts:
  platform: marytts
  host: 172.17.0.2

I use the following script in some automations, and it all worked fine up until yesterday.

sonos_say:
    alias: "Sonos TTS script with restore"
    sequence:
      - service: sonos.snapshot
        data_template:
          entity_id: "{{ sonos_entity|default('media_player.kitchen_sonos') }}"
      - service: media_player.volume_set
        data_template:
          entity_id: "{{ sonos_entity|default('media_player.kitchen_sonos') }}"
          volume_level: "{{ volume|default(0.4) }}"  # orig 0.5
      - service: tts.marytts_say
        data_template:
          entity_id: "{{ sonos_entity|default('media_player.kitchen_sonos') }}"
          message: "{{ message }}"
      - wait_template: "{{ is_state(sonos_entity|default('media_player.kitchen_sonos'), 'playing') }}"
        timeout: '00:00:30'
      - wait_template: "{{ not is_state(sonos_entity|default('media_player.kitchen_sonos'), 'playing') }}"
        timeout: '00:01:00'        
      - service: sonos.restore
        data_template:
          entity_id: "{{ sonos_entity|default('media_player.kitchen_sonos') }}"

Today, I can click on my media player in the front end, type in a message, and hear the TTS on my Sonos. But if I go to services and try to use tts.marytts_say, or run the script above (which is using the same service), I get the following error:

2020-02-23 13:22:38 ERROR (SyncWorker_7) [homeassistant.components.sonos.media_player] Error on play_media with UPnP Error 714 received: Illegal MIME-Type from 192.168.0.125

That IP is my Sonos speaker. I think the issue may be that the new TTS files end with .wave_file, whereas they used to end with .wav, and the media player isn’t handling this, but I’m not sure.

I’d really appreciate any help to get my TTS announcements on my Sonos working again. Thanks in advance!

1 Like

did you manage to resolve this issue? I also encounter this using marytts with my sonos

No, I have an issue open on GitHub but there hasn’t been any action on it. I really miss having TTS working in HA - it worked great until the changes to the platform in 0.105. As far as I know MaryTTS is the only self-hosted option available at the moment, but maybe there aren’t enough people using it to make it a priority for the devs.

You could use https://github.com/Poeschl/Remote-PicoTTS in the meantime, however the quality isn’t as good

1 Like

Thanks for pointing that out. I’ll take a look when I get a chance. But I’m really hoping MaryTTS will get fixed sooner rather than later :crossed_fingers:

You are exactly right!

If you want a quick fix until your issue is resolved, you can change the file
/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/tts/__init__.py

The following line
filename = f"{key}.{extension}".lower()
to
filename = f"{key}.wav".lower()

However this might break other tts services.
I would like to have this fixed, but I am not sure wether they accept a pull request just for that.

How are the Integrations maintained in Home Assistant?

1 Like

Thanks very much for your comment. I’m running HA Supervised on an Ubuntu host (formerly Hass.io), so I don’t think I can access/edit that file - someone tell me if I’m wrong. Otherwise I’d do it - I’m not using any other TTS.

You could try a PR. I filed an issue I filed on GitHub here, but it’s not getting much activity:

I’d really like for this to be fixed, too.

hi @darioce,
are you running HA via Docker?
I don’t have anything under /srv on my host system, does this file need to be modified on the docker image?

(sorry for noob questions)

The above changes only work if you are using the virtual environment.
It is a bit trickier to do it with docker.
But you can try to start a bash inside the container using

docker exec -it DOCKER_IMAGE_HASH /bin/bash

and then modify the file

/usr/src/homeassistant/homeassistant/components/tts/__init__.py

Don’t forget to restart Home Assistant afterwards.
The problem is, that you need to apply this fix everytime you update the container.

I have already submitted a pull request to fix this but it has not been included yet.

1 Like

Thanks very much for submitting the PR! I hope it gets accepted soon.

Thanks a lot @darioce… unfortunately this didn’t work for me, though I can confirm the changes persisted after homeassistant restart.
I can confirm the files are now named correctly (ending with the .wav extension), but still getting the same error in the developer logs stating ‘error on Load tts: Wrong tts file format!
before making this change the audio was playing via the localhost:59125 mary tts web interface. now even that is not working.

will wait for the your fix to get incorporated, hopefully that’ll resolve the issue.

@darioce I see the PR is waiting for tests…do you have any update on this?

I have to get myself accustomed to the test framework. Planning to be done this weekend, but not sure whether I manage to meet the dev’s standards on the first try :sweat_smile:

Thanks for the update. I’m glad to hear it hasn’t completely stalled. Good luck with the testing! :slight_smile: :+1:

@darioce Not trying to be pushy…just wanted to let you know that issue was going to be marked as stale on GitHub so I have added a comment to say that it is still an open issue. Were you able to get anywhere with the test framework?

I am super busy at work at the moment and really would need to get myself thoroughly accustomed to the testing framework.

If anyone has experience with this, some help would be greatly appreciated.

Sorry, for dragging out this issue…

No worries, obviously your job is more important! Hopefully there may be someone else who can help…