Announcement

Collapse
No announcement yet.

sending voice from scripts to sonos speakers?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    sending voice from scripts to sonos speakers?

    Ok after much trial and error I was finally able to get my TTS working with my Zee S2 and my Sonos speakers. The only drawback after all this work is that the voice sounds too robotic and is difficult to understand. Hence I searched for other more natural speech alternatives. I came upon the RPi text to speech web page which provided a script which would provide a more natural sounding voice via googles TTS engine. I got the script working (attached as a text file) via the command line and was even able to get it to run via a HS3 event, however, to run the script as a HS3 event I needed to use the "run another program or process" action in HS3 which doesn't allow selecting a speaker client.

    Anyone have any ideas how I can use the voice script along with the sonos PI? Is there a way to use the "speak" action but insert the script and text inside the field?
    Attached Files

    #2
    Originally posted by wdeertz View Post
    Ok after much trial and error I was finally able to get my TTS working with my Zee S2 and my Sonos speakers. The only drawback after all this work is that the voice sounds too robotic and is difficult to understand. Hence I searched for other more natural speech alternatives. I came upon the RPi text to speech web page which provided a script which would provide a more natural sounding voice via googles TTS engine. I got the script working (attached as a text file) via the command line and was even able to get it to run via a HS3 event, however, to run the script as a HS3 event I needed to use the "run another program or process" action in HS3 which doesn't allow selecting a speaker client.

    Anyone have any ideas how I can use the voice script along with the sonos PI? Is there a way to use the "speak" action but insert the script and text inside the field?
    Most people use announcements that are always the same, no variable part in it. If you have those, you can record them only once, any way you want, and just play a sound file (you enter the FULL path name in the text field of the "speak" event. You could use the same principle if you were to say make speech files using an external tool. You would have a single event with two actions. First action, you would create the file and then have a second action play it on your Sonos player with same principle as described above. If unclear, read the help file how to play sound files or concatenate multiple items in a single Sonos Announcement.

    Dirk

    Comment


      #3
      Originally posted by dcorsus View Post
      Most people use announcements that are always the same, no variable part in it. If you have those, you can record them only once, any way you want, and just play a sound file (you enter the FULL path name in the text field of the "speak" event. You could use the same principle if you were to say make speech files using an external tool. You would have a single event with two actions. First action, you would create the file and then have a second action play it on your Sonos player with same principle as described above. If unclear, read the help file how to play sound files or concatenate multiple items in a single Sonos Announcement.

      Dirk
      Dirk, ok thanks for the suggestions. I was able to get it to work with wav files but the mp3 files didn't work. These were simple short announcements. Any idea why a mp3 wouldn't be played?

      Comment


        #4
        Originally posted by wdeertz View Post
        Dirk, ok thanks for the suggestions. I was able to get it to work with wav files but the mp3 files didn't work. These were simple short announcements. Any idea why a mp3 wouldn't be played?
        Should work as well. Maybe post the event screenshot and .mp3 file. Make sure it is an MP3 file and not a file that got an .mp3 extension. Some players are smart enough to figure out what file format they are dealing with irrespective of the file extension. Check the Sonos APP when the file plays, do you see an error popping up.

        Dirk

        Comment


          #5
          Originally posted by dcorsus View Post
          Should work as well. Maybe post the event screenshot and .mp3 file. Make sure it is an MP3 file and not a file that got an .mp3 extension. Some players are smart enough to figure out what file format they are dealing with irrespective of the file extension. Check the Sonos APP when the file plays, do you see an error popping up.

          Dirk
          Dirk, I checked the log and didn't see any error messages. In any event it was just as easy for me to convert all the mp3 announcements to wav files. It seems to be working well now. Thanks

          Comment


            #6
            Originally posted by wdeertz View Post
            Dirk, I checked the log and didn't see any error messages. In any event it was just as easy for me to convert all the mp3 announcements to wav files. It seems to be working well now. Thanks
            Not the error log, what do you see on the Sonos app when it tried to play thit mo3
            Dirk

            Comment


              #7
              Dirk, I was able to get most of my static announcements working perfectly with wav files being output to my sonos speakers, thanks so much for your handy plug-in. The process of creating the text to speech wav files is a little convoluted and time consuming so I'd still like to be able to speak simple text announcements to the sonos speakers on the fly. After thoroughly searching the forums I found that the HS3 uses the scripts speak.sh and speak_to_file.sh located in /usr/local/homeseer/ directory. I used Dan Fountain's script (attached file) to use the google text to speech and it works very well. Now when I do a HS3 event with "speak something" I get the soothing voice provided by google instead of the robotic flite voice. The problem occurs when I input my $SONOS$TTSALL$ in the speaker client.

              The audio comes out of the Zee hdmi port as "slash usr slash local slash homeseer slash html slash sonos slash announcements slash underscore... then something too garbled for me to understand. It seems that there is a wrong file location in either the script or the plug-in doesn't like what is being passed to it from the script. The Songs plug-in seems to be looking for a file in the \usr\local\homeseer\html\sonos\announcements\ directory. Any idea how I can get this script to play nicely with the Songs plug-in?
              Attached Files

              Comment


                #8
                Originally posted by wdeertz View Post
                Dirk, I was able to get most of my static announcements working perfectly with wav files being output to my sonos speakers, thanks so much for your handy plug-in. The process of creating the text to speech wav files is a little convoluted and time consuming so I'd still like to be able to speak simple text announcements to the sonos speakers on the fly. After thoroughly searching the forums I found that the HS3 uses the scripts speak.sh and speak_to_file.sh located in /usr/local/homeseer/ directory. I used Dan Fountain's script (attached file) to use the google text to speech and it works very well. Now when I do a HS3 event with "speak something" I get the soothing voice provided by google instead of the robotic flite voice. The problem occurs when I input my $SONOS$TTSALL$ in the speaker client.

                The audio comes out of the Zee hdmi port as "slash usr slash local slash homeseer slash html slash sonos slash announcements slash underscore... then something too garbled for me to understand. It seems that there is a wrong file location in either the script or the plug-in doesn't like what is being passed to it from the script. The Songs plug-in seems to be looking for a file in the \usr\local\homeseer\html\sonos\announcements\ directory. Any idea how I can get this script to play nicely with the Songs plug-in?
                I can't help you with the script but I can tell you what the PI does. It takes the text you provided, verbatim, and try to open that as a file. If it opens successful, it assumes it is a file name and streams the file to a player. If it can't open a file, it assumes it is text and forwards it to HS3 for a text to speech-file conversion. So in you case, whatever you fed the PI isn't representing an existing file so you hear it spoken. So either you script is not outputting a file where you are pointing the PI towards, or the file is corrupt or the file has the wrong permissions and the PI can't open it.

                Hope that helps, I can't tell from the script where the output goes...

                Dirk

                Comment


                  #9
                  Dirk, ok thanks for the explanation, that helps somewhat.

                  Does the plug-in create a wav file in /usr/local/homeseer/html/sonos/announcements the first time a message is played?

                  That directory includes a bunch of wav files which are identical to the wav files which are used in my events and held in a separate directory. ANN_TTSALL_1, ANN_TTSALL_2, etc., where TTSALL is my sonos PI link group name. It appears ANN_TTSALL_0 is the file created by the speak_to_file.sp script and is unable to be found by the sonos plug-in, see attached screen shot.

                  I'll keep search to try and figure out where the script is going wrong.
                  Attached Files

                  Comment


                    #10
                    Originally posted by wdeertz View Post
                    Does the plug-in create a wav file in /usr/local/homeseer/html/sonos/announcements the first time a message is played?
                    Not just the first time, it creates a file EACH time you do a "Speak" event that uses the Sonos PI to generate speech from text. The file names are based on which linkgroup you used and whether there are multiple consecutive announcements being queued. You should NOT be concerned how the PI names the files. There are just 2 ways to use this PI properly, either you do the standard text to speech, the PI will call HS who in terms calls whatever subsystem it uses on which platform. Under Linux it should be flite for text to file and the intermediary script file is indeed speak-to-file.sh. The content of mine is a simple pass through flite -o "S1" -t "S2". The PI will call HS with two parameters: 1/ the text string to convert and 2/ the file name (and path!) where to write the resulting speech file. So if you want to NOT use flite but something else, remember, USE the parameters provided and all will work if the result is a file, with the name provided AND this is a .wav file format.

                    If you don't like the above, the other way is that you generate a file, name it anyway you want, in a file format that has the right extension AND is supported by Sonos and you just put the full file name in the text string for the announcement.

                    Originally posted by wdeertz View Post
                    That directory includes a bunch of wav files which are identical to the wav files which are used in my events and held in a separate directory. ANN_TTSALL_1, ANN_TTSALL_2, etc., where TTSALL is my sonos PI link group name. It appears ANN_TTSALL_0 is the file created by the speak_to_file.sp script and is unable to be found by the sonos plug-in, see attached screen shot.
                    If you make your own files DO NOT name them after what you find in the announcement subdirectory because the files will be overwritten. If you use your own files, perhaps keep them in a different directory or make sure they have a unique name.
                    What is the content of your speak_to_file.sp script?

                    Dirk

                    Comment


                      #11
                      Dirk, I connected a monitor to the Zee S2 and noted during boot up and loading of the Sonos plugin the error message - "object reference not set to an instance of an object".

                      Not sure if this is related to the issues I am having or not. It mentions the MediaAPI but I don't have that box checked. Any idea on possible solutions to eliminate error?

                      Comment


                        #12
                        Originally posted by wdeertz View Post
                        Dirk, I connected a monitor to the Zee S2 and noted during boot up and loading of the Sonos plugin the error message - "object reference not set to an instance of an object".

                        Not sure if this is related to the issues I am having or not. It mentions the MediaAPI but I don't have that box checked. Any idea on possible solutions to eliminate error?
                        Don't hook up a monitor
                        Seriously, it is a benign error, hence why you don't even see it in the regular log

                        Comment


                          #13
                          Originally posted by dcorsus View Post
                          Don't hook up a monitor
                          Seriously, it is a benign error, hence why you don't even see it in the regular log

                          Comment

                          Working...
                          X