thlucas1 / homeassistantcomponent_soundtouchplus

Home Assistant integration for Bose SoundTouch speakers
MIT License
13 stars 1 forks source link

Create entities under the tts domain #16

Closed override80 closed 6 months ago

override80 commented 6 months ago

Checklist

Is your feature request related to a problem? Please describe.

Hi again @thlucas1 ,

i'm wondering if it makes any sense to you to publish an entity for the soundtouchplus.play_tts as an entity under the tts domain as detailed here: https://www.home-assistant.io/integrations/tts/#service-speak, so we can use it with the tts.speak service.

Describe the solution you'd like

Use tts.speak service as a general method to invoke tts having soundtouchplus.play_tts as tts. entity.

Describe alternatives you've considered

Keep using it as it is

Additional context

no other context

thlucas1 commented 6 months ago

Hi @override80 - I could do what you ask, but the call to play the message would still fail. The reason for that is that the various TTS services that I have tried all result in an MP3 file being generated that is of a format that the SoundTouch speaker cannot understand; more specifically, the bit rate of the MP3 file. Note that the SoundTouchPlus Play TTS services utilizes the http://translate.google.com/translate_tts?... service to generate the MP3 data to play for the message, which generates an MP3 file with a supported bitrate that the SoundTouch speaker understands. The SoundTouch speaker supports the following file types (and bit rates):

The best I could do is to intercept any announcement (e.g. media_id starts with media-source://tts/?) type of request in the async_play_media event, and re-direct it to play via the http://translate.google.com/translate_tts?... service. Note that in doing so, you would lose any options that you specified (e.g. language, etc). Note that this would only affect the SoundTouchPlus media player, and not any other media players that utilize TTS.

Another options is to see if you can specify custom options on the TTS service that will instruct the TTS provider to generate a specific file format that is compatible with the SoundTouch speaker. I have looked, but not having much luck with that approach.

thlucas1 commented 6 months ago

@override80 I pushed out version 1.0.32 with the new "TTS Force Google Translate" option. As stated in my previous reply, it intercepts any announcement (e.g. media_id starts with media-source://tts/?) type of request in the async_play_media event, and re-directs it to play via the SoundTouchPlus Play TTS service.

Check out the Project Wiki for details on how to configure it. It's just a simple boolean switch to turn it on or off via the Configure Options form for each SoundTouch device.

All 3 of the TTS options I have installed now work, even though they are calling Google Translate under the covers: image

Please let me know if this works for you or not.

Thanks - Todd

override80 commented 6 months ago

Hi Todd,

thanks for the quick implementation! I can successfully play TTS messages on my ST-10 (of course the ST-20 does not work as it didn't before, because tts is not supported):

- service: tts.speak
  data:
    media_player_entity_id: tts.google_en_com
    message: 'Hello'
  target:
    entity_id: media_player.soundtouch_10_bedroom

or

- service: tts.speak
  data:
    media_player_entity_id: tts.piper
    message: 'Hello'
  target:
    entity_id: media_player.soundtouch_10_bedroom

Just one question: the volume is pretty low, do you have any idea how can i raise it :sweat_smile:? Using media_player.set_volume just before doesn't seem to work.

thlucas1 commented 6 months ago

@override80 I pushed out version 1.0.33 to fix the volume level.

It was using a static value of 30 for the volume. I changed it to zero, which forces the current volume level of the SoundTouch device to be used. You can set any volume level you wish before the TTS call using the media_player.set_volume call.

Just have to install v1.0.33 first.

thlucas1 commented 6 months ago

Hi @override80 - Please let me know if this fixes your issue, and I will close the issue. Thanks.

override80 commented 6 months ago

Sure! :)

Thankyou @thlucas1 !