Jump to content

What's the best way to do TTS through Sonos?


raymondh

Recommended Posts

Assuming that the Sonos has a line level input, you could use a RaspberryPi with Festival for TTS and plug the audio from the Pi into the Sonos.  ISY could then send a network command to the Sonos to select the line in and follow that with a request to the Pi to speak your message, then another command to the Sonos to reselect the previous source.

 

I do not yet own a Sonos so some assumptions have been made on my part as to the capabilities of the sonos and the ISY's ability to control it.

 

For reference, here is a link to TTS on a Pi: http://elinux.org/RPi_Text_to_Speech_%28Speech_Synthesis%29

 

Hope this helps.

 

-Xathros

Link to comment

I purchased a Sonos today and will be using it for voice alerts as well. I started playing around with it and it seems to be able to do what we want. 

 

I use a program called EventGhost and the Sonos plugin available here: http://www.eventghost.net/forum/viewtopic.php?f=9&t=6078&p=30309#p30309

 

Then I use the network resources module on the ISY to GET a URL from the EventGhost application, and depending on what URL the ISY retrieves, it will send a command to the Sonos. (play a certain track, volume up, down, pause, etc) There are tons of commands that Eventghost can send to the Sonos. Now I just need to get some voiceovers recorded for the alerts I want and then tell the Sonos to play the MP3 file. 

Link to comment

If you don't mind running a box (I use Raspberry Pi's) I can pull together my Sonos integration scripts, you can play, group, etc and do TTS (at least against input scripts, I convert them and run them to the zones).  Tie in to ISY is via device ID's and/or variables (e.g. you can say when switch X turns on then group these devices, select this favorite, play or you can say when variable X is 2 then play this favorite, etc)...

Bill

Link to comment

I purchased a Sonos today and will be using it for voice alerts as well. I started playing around with it and it seems to be able to do what we want. 

 

I use a program called EventGhost and the Sonos plugin available here: http://www.eventghost.net/forum/viewtopic.php?f=9&t=6078&p=30309#p30309

 

Then I use the network resources module on the ISY to GET a URL from the EventGhost application, and depending on what URL the ISY retrieves, it will send a command to the Sonos. (play a certain track, volume up, down, pause, etc) There are tons of commands that Eventghost can send to the Sonos. Now I just need to get some voiceovers recorded for the alerts I want and then tell the Sonos to play the MP3 file.

 

Can you provide a walk through on how you do this? I've installed Eventghost and the Sonos plugin. I haven't integrated ISY into this yet as I would like to get things working through just Eventghost before I start messing with ISY in the mix.

 

I can get EG to pause and play if I already have it playing from the Sonos app but I don't see how to make it play something specific.

Link to comment

If you don't mind running a box (I use Raspberry Pi's) I can pull together my Sonos integration scripts, you can play, group, etc and do TTS (at least against input scripts, I convert them and run them to the zones).  Tie in to ISY is via device ID's and/or variables (e.g. you can say when switch X turns on then group these devices, select this favorite, play or you can say when variable X is 2 then play this favorite, etc)...

Bill

I don't mind running one of these since they're tiny and solid state. If I understand correctly, the sonos control and tts would run on the Raspberry Pi and ISY would use network resources to send commands to it? How is the TTS? Is it as natural sounding as Google TTS?

Link to comment

Can you provide a walk through on how you do this? I've installed Eventghost and the Sonos plugin. I haven't integrated ISY into this yet as I would like to get things working through just Eventghost before I start messing with ISY in the mix.

 

I can get EG to pause and play if I already have it playing from the Sonos app but I don't see how to make it play something specific.

 

I actually changed it a bit so that I don't have to use event ghost. What I did was create a new network resource with the following:

 

http://screencast.com/t/n5vVwNLkH7

 

For the Host, change the IP address to the local IP address of your Sonos speaker. Make sure the path is set to "/MediaRenderer/AVTransport/Control" (without the quotes)

 

Click "Add" on the left side to add a SOAPACTION and enter the following into the value "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"  (You'll actually need the quotes when you past this one in) 

 

In the "body" enter the following: 

<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
      <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
         <InstanceID>0</InstanceID>
         <CurrentURI>x-file-cifs://NETWORKSTORAGE/Music/SmarthomeSounds/Welcome.mp3</CurrentURI>
         <CurrentURIMetaData />
      </u:SetAVTransportURI>
   </s:Body>
</s:Envelope>

You'll see on line 5 the CurrentURI Tags with a link to cifs://  network resource. Replace this URL with the URL of the MP3 file you are wanting to play. The network resource must be accessible by your Sonos player. If the directory is password protected, then add the directory in the Windows Sonos controller app with the username/password of the directory so it will be able to log in.

 

When you run that network resource, it will select the file, but not play it, so remember to create another network resource to "play" the file after it has been selected. Here is the code to play. Let me know if this helps!
 
POST /MediaRenderer/AVTransport/Control HTTP/1.1
Host: 192.168.1.25:1400
Connection: Close
Content-Type: text/xml; charset="utf-8"
Content-Length: 267
SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Play"

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope>

Link to comment

Yipes!  I guess it's not as straight forward to add voice announcements to ISY as I was hoping.  In the early 90's I used Homeseer and it was so easy to do announcements.  I have a tiny windows computer that I'm trying to get something working for voice through Sonos but so far everything is a bit complicated (or I'm slow, impatient, or both!)

 

:-)

Link to comment

I've played around with using Google's tts and network resources with my squeezebox devices to do this. If the Sonos can play a link like ...

 

http://translate.google.com/translate_tts?tl=en&q=Hello%20world

 

... then it may be an option that doesn't require another box.

 

Sonos can play a link like that. I just verified it works. There is about a 5 second delay before it starts playing, and it cuts of the last 1/2 second and continues to repeat until you send a command to stop. 


<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID>,<CurrentURI>x-rincon-mp3radio://translate.google.com/translate_tts?tl=en&q=Hello+world</CurrentURI>,<CurrentURIMetaData></CurrentURIMetaData></u:SetAVTransportURI></s:Body></s:Envelope>
Link to comment

I tried to get this working but I got the following error. 

 

"TCP Client request failed

NetModule Rule 9: 500"

 

Any obvious that I am doing wrong?

 

POST /MediaRenderer/AVTransport/Control HTTP/1.1
Host: 192.168.1.24:1400
User-Agent: Mozilla/4.0
Connection: Close
Content-Type: text/xml; charset="utf-8"
Content-Length: 454
SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Play"
 
   <s:Body>
      <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
         <InstanceID>0</InstanceID>
         <CurrentURI>x-rincon-mp3radio://translate.google.com/translate_tts?tl=en&q=Hello+world</CurrentURI>
         <CurrentURIMetaData />
      </u:SetAVTransportURI>
   </s:Body>
</s:Envelope>
Link to comment

 

I tried to get this working but I got the following error. 

 

"TCP Client request failed

NetModule Rule 9: 500"

 

Any obvious that I am doing wrong?

 

POST /MediaRenderer/AVTransport/Control HTTP/1.1
Host: 192.168.1.24:1400
User-Agent: Mozilla/4.0
Connection: Close
Content-Type: text/xml; charset="utf-8"
Content-Length: 454
SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Play"
 
   <s:Body>
      <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
         <InstanceID>0</InstanceID>
         <CurrentURI>x-rincon-mp3radio://translate.google.com/translate_tts?tl=en&q=Hello+world</CurrentURI>
         <CurrentURIMetaData />
      </u:SetAVTransportURI>
   </s:Body>
</s:Envelope>

 

I tlooks like you are trying to play a file. You need to Change the SOAPACTION to the following: 

 

"urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"

 

That will tell the sonos speaker to queue up that file. Then you need to run a separate command to tell it to play it. 

 

POST /MediaRenderer/AVTransport/Control HTTP/1.1
Host: 192.168.1.25:1400
Connection: Close
Content-Type: text/xml; charset="utf-8"
Content-Length: 267
SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#Play"
 
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:Play xmlns:u="urn:schemas-upnp-org:service:AVTransport:1"><InstanceID>0</InstanceID><Speed>1</Speed></u:Play></s:Body></s:Envelope>
Link to comment
Ok, I did that but I still can get the file to work. I can get my speaker to play through ISY but I can't seem to get the track loaded? Any other suggestions? Here is my latest effort. I am getting a TCP rule 9 error.

 

 

 

 

POST /MediaRenderer/AVTransport/Control HTTP/1.1

Host: 192.168.1.24:1400

User-Agent: Mozilla/4.0

Connection: Close

Content-Type: text/xml; charset="utf-8"

Content-Length: 476

SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"

 


   <s:Body>

      <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">

         <InstanceID>0</InstanceID>

         <CurrentURI>x-rincon-mp3radio://translate.google.com/translate_tts?tl=en&q=%22andy%20has%20left%20interlocken%22</CurrentURI>

         <CurrentURIMetaData />

      </u:SetAVTransportURI>

   </s:Body>

</s:Envelope>

Link to comment

 

Ok, I did that but I still can get the file to work. I can get my speaker to play through ISY but I can't seem to get the track loaded? Any other suggestions? Here is my latest effort. I am getting a TCP rule 9 error.
 
 
 
 
POST /MediaRenderer/AVTransport/Control HTTP/1.1
Host: 192.168.1.24:1400
User-Agent: Mozilla/4.0
Connection: Close
Content-Type: text/xml; charset="utf-8"
Content-Length: 476
SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"
 
   <s:Body>
      <u:SetAVTransportURI xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
         <InstanceID>0</InstanceID>
         <CurrentURI>x-rincon-mp3radio://translate.google.com/translate_tts?tl=en&q=%22andy%20has%20left%20interlocken%22</CurrentURI>
         <CurrentURIMetaData />
      </u:SetAVTransportURI>
   </s:Body>
</s:Envelope>

 

You are missing a "amp;" in Google's TTS URL. The URL should be:

translate.google.com/translate_tts?tl=en&q=%22andy%20has%20left%20interlocken%22
Link to comment
  • 2 weeks later...

Could anyone familiar with this solution tell me if this is possible?

 

I'd like to be able to interrupt a playing track/radio station etc and play a sound file, then resume the track/station. It's so I can hook my driveway alarm into the sound system rather than have yet another speaker, I'd like to use the existing Sonos system for that.

 

Any ideas if I can do that?

Link to comment

I was really rather wanting to do it without adding yet another piece of hardware to the setup...

 

Though I do have a pc running all the time on the network. So I might take a look at adding something, but preference would be to stay just with ISY to keep point of failure to a minimum.

Link to comment
  • 1 year later...

Archived

This topic is now archived and is closed to further replies.


×
×
  • Create New...