Announcement

Collapse
No announcement yet.

Change Windows TTS voice by script - Solution!

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

  • Change Windows TTS voice by script - Solution!

    I have several TTS voices and I want to have a different one play each day. I'm trying to use a script to change the voice in windows TTS. I am aware of the voice tag <voice required> but don't want to use this method as it is only temporary.

    Code:
    Imports System.Speech
    Sub Main (Parm as Object)
    System.Speech.SpeechSynthesizer.SelectVoice("IVONA 2 Amy OEM")
    End Sub
    My config.settings.ini file has this entry:

    Code:
    ScriptingReferences= System.Speech;System.Speech.dll
    On start up I get these errors:


    Feb-03 6:34:00 AM Error Compiling script Startup.vb: compiler initialization failed unexpectedly: The system cannot find the file specified.
    Feb-03 6:34:00 AM Error Compiling script Startup.vb: could not find library 'System.Speech.dll'

    When I check ReferenceAssemblies/Microsoft/Framework/v3.0, System.Speech.dll is in there.

    These are my Homeseer Stats:

    Current Date/Time: 2/3/2017 6:44:12 AM
    HomeSeer Version: HS3 Pro Edition 3.0.0.297
    Operating System: Microsoft Windows 7 Professional - Work Station
    System Uptime: 0 Days 0 Hours 10 Minutes 21 Seconds
    IP Address: 192.168.0.97
    Number of Devices: 451
    Number of Events: 78
    Available Threads: 400

    Enabled Plug-Ins
    3.0.0.29: ADIO-100
    3.4.1.0: Caddx
    3.0.0.75: HSTouch Server
    3.1.0.18: Sonos
    3.0.5725.16923: UltraCID3
    3.0.1.87: Z-Wave

    Any ideas?

  • #2
    I'm not convinced that this option changes the system default voice, I've done work in the past with the System.Speech DLL (I had a plugin that replaced the speaker client for TTS only) but not looked at it for a while - I believe setting this is only for the duration of the script rather than changing the system behaviour. I believe the control for this was in the registry somewhere.
    My Plugins:

    Pushover 3P | DoorBird 3P | Current Cost 3P | Velleman K8055 3P | LAMetric 3P | Garadget 3P | Hive 3P |
    Yeelight 3P | Nanoleaf 3P

    Comment


    • #3
      Thanks for the reply and you may be right.

      I might still be able to use it on a temporary basis. I'd like to figure out why my script can't load or find system.speech.dll.

      Am I referencing it wrong in my config.settings.ini file?

      I tried Microsoft.speech;Microsoft.speech.dll and that didn't work either.

      Comment


      • #4
        I don't know if this will work or not, but you could try it. Create a virtual device and set up status pairs, 1 for each voice. Then have a script and/or event change the "value" of that device each day. Then in your announcements put the <voice required> tag like this:

        <voice required="Name = $$DSR:1234:">Announcement text here


        Where 1234 is the device reference of the virtual device above.

        Just a thought, and I'm not 100% sure the replacement variable will work there, but I'm about 90% sure it will
        Thanks,
        Frank

        Comment


        • #5
          Originally posted by sirmeili View Post
          I don't know if this will work or not, but you could try it. Create a virtual device and set up status pairs, 1 for each voice. Then have a script and/or event change the "value" of that device each day. Then in your announcements put the <voice required> tag like this:

          <voice required="Name = $$DSR:1234:">Announcement text here


          Where 1234 is the device reference of the virtual device above.

          Just a thought, and I'm not 100% sure the replacement variable will work there, but I'm about 90% sure it will
          I did a quick test and this works quite well for me. (ignore the BLSpeech special processing tags between the {})
          Attached Files
          Thanks,
          Frank

          Comment


          • #6
            Thanks. That works perfectly.

            Comment


            • #7
              Originally posted by prsmith777 View Post
              I have several TTS voices and I want to have a different one play each day. I'm trying to use a script to change the voice in windows TTS. I am aware of the voice tag <voice required> but don't want to use this method as it is only temporary.

              Code:
              Imports System.Speech
              Sub Main (Parm as Object)
              System.Speech.SpeechSynthesizer.SelectVoice("IVONA 2 Amy OEM")
              End Sub
              My config.settings.ini file has this entry:

              Code:
              ScriptingReferences= System.Speech;System.Speech.dll
              On start up I get these errors:


              Feb-03 6:34:00 AM Error Compiling script Startup.vb: compiler initialization failed unexpectedly: The system cannot find the file specified.
              Feb-03 6:34:00 AM Error Compiling script Startup.vb: could not find library 'System.Speech.dll'

              When I check ReferenceAssemblies/Microsoft/Framework/v3.0, System.Speech.dll is in there.

              Any ideas?
              Have you tried removing the space between the = sign and System?

              Cheers
              Al
              HS 3.0.0.548: 1976 Devices 1156 Events
              Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

              Comment


              • #8
                I just tried it myself and got the same error as you did. I had to provide the whole path to the dll in the settings.ini:

                Code:
                System.Speech;C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.Speech.dll
                I used this script to test it:

                Code:
                Imports System.Speech.Synthesis
                
                Sub Main(ByVal Parms as String)
                 
                	Dim Debug as Boolean = True
                	Dim logName As String = "Voices"
                	Dim synth As New SpeechSynthesizer
                	Dim voices = synth.GetInstalledVoices()
                	For Each v As InstalledVoice In voices
                		If Debug Then hs.writelog(logName,v.VoiceInfo.Name)
                	Next
                
                End Sub
                Cheers
                Al
                HS 3.0.0.548: 1976 Devices 1156 Events
                Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

                Comment


                • #9
                  Nice work. Thanks

                  Comment


                  • #10
                    Some more testing indicates that .SelectVoice does not change the default voice and doesn't seem to have any effect on the hs.speak commands. You probably could use the script to cycle through the voices daily and change the virtual device that way.

                    Cheers
                    Al
                    HS 3.0.0.548: 1976 Devices 1156 Events
                    Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

                    Comment


                    • #11
                      Originally posted by sparkman View Post
                      Some more testing indicates that .SelectVoice does not change the default voice and doesn't seem to have any effect on the hs.speak commands. You probably could use the script to cycle through the voices daily and change the virtual device that way.

                      Cheers
                      Al
                      it only changes the 64 bit selected voice and not the capi.cpl accessible 32bit voice. I am tryi to do the same but no luck yet to change the active 32 bit voive (used by hs3)


                      any help?

                      bart
                      Regards Bart
                      ------------------------------------------
                      Win7 64Bit on Intel NUCI7 with SSD
                      HSPRO 3.
                      Devices; 1370 Events; 691

                      Jon00 Scripts, JowHue, HSTouch, Plugwise, Z-wave, Ultranetatmo, Ultracam, PHlocation, BLUSBUIRT, MeiHarmony, Buienradar, MEiUnifi Pushover 3P, Random, Nest HSPhone and Blueiris

                      Visonic Powermax Alarm System (HS3) Interface: http://www.domoticaforum.eu/viewtopic.php?f=68&t=11129

                      Comment

                      Working...
                      X