Announcement

Collapse
No announcement yet.

Script TTS Pronounciation

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

    #16
    Originally posted by Gogs View Post
    Thanks, but $$DTR still will not reveal the value to x,
    That is because on most devices $$DTR:xxxx: will return a blank, because there is nothing stored as a string. What you need to do for speaking is to use a small script to take the value hs.DeviceValueEX, truncate it to a single digit after the decimal point, replace "-" with "minus" and append "degrees" or "degrees celsius" to the value to use in spoken text. You can use alternately hs.DeviceValue to return an integer, if that is all the precision you need. Unfortunately, I am not a programmer, but I could cobble something together. I would probably write it to a Virtual Device's string, but it could be written to the actual Device's string, but then it would look like this:

    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	5.9 KB
ID:	1194728

    Then you could use $$DTR:618: ("minus 2 degrees celcius") in your speech string for the temperature.

    If you don't need to refer to the device with Device Manager or HSTouch, it wouldn't be a problem.
    HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

    Comment


      #17
      Originally posted by Uncle Michael View Post
      My installation of HS3 supports both. What have you tried that leads you to think that HS3 doesn't support hs.DeviceString()?
      Simply that I have never managed to get them to work with HS3
      sigpic
      A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

      Comment


        #18
        Originally posted by rprade View Post
        That is because on most devices $$DTR:xxxx: will return a blank, because there is nothing stored as a string. What you need to do for speaking is to use a small script to take the value hs.DeviceValueEX, truncate it to a single digit after the decimal point, replace "-" with "minus" and append "degrees" or "degrees celsius" to the value to use in spoken text. You can use alternately hs.DeviceValue to return an integer, if that is all the precision you need. Unfortunately, I am not a programmer, but I could cobble something together. I would probably write it to a Virtual Device's string, but it could be written to the actual Device's string, but then it would look like this:

        [ATTACH]65725[/ATTACH]

        Then you could use $$DTR:618: ("minus 2 degrees celcius") in your speech string for the temperature.

        If you don't need to refer to the device with Device Manager or HSTouch, it wouldn't be a problem.
        sigpic
        A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

        Comment


          #19
          Originally posted by Gogs View Post
          Simply that I have never managed to get them to work with HS3
          Did you try this and it didn't work? What did you get? Were there any error messages?

          x = "Good "& TimeOfDay() & ".. The time is " & myTime() & "..It is" & WeekdayName(DatePart("w", Date)) & MonthName(DatePart("m", Date))& ",,the" & myday() & "," & "and the current outside temperature is " & hs.DeviceString(408) & "but it feels like " & hs.DeviceString(418)
          Mike____________________________________________________________ __________________
          HS3 Pro Edition 3.0.0.548, NUC i3

          HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

          Comment


            #20
            Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	32.9 KB
ID:	1194729

            Here is the Status Graphics page where it is selected to have 1 decimal place for the status text

            Click image for larger version

Name:	Capture1.PNG
Views:	1
Size:	32.3 KB
ID:	1194730

            Depending on how your device's value is set by the plug-in, it may have way too much precision for a spoken value. That is why you would truncate it or use hs.DeviceValue so that it is only the integer. All you need to do is look at the Advanced tab to see the real precision of your device.

            I don't do scripting much, but I will see if I can figure something out.
            HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

            Comment


              #21
              Originally posted by Uncle Michael View Post
              Did you try this and it didn't work? What did you get? Were there any error messages?

              x = "Good "& TimeOfDay() & ".. The time is " & myTime() & "..It is" & WeekdayName(DatePart("w", Date)) & MonthName(DatePart("m", Date))& ",,the" & myday() & "," & "and the current outside temperature is " & hs.DeviceString(408) & "but it feels like " & hs.DeviceString(418)
              That should work, but would still have the original problem he was trying to resolve - that negative temperatures spoken are "dash 2.3 degrees", because TTS pronounces "-" as "dash". That is why I proposed processing the value to make a useable text string and storing it as the device's string or in another virtual device.

              I think the only problem with your suggestion above is that you cannot use replacement variables in a script. There is a scripting function to use them, but I don't recall what it is.
              Last edited by randy; January 8, 2018, 04:56 PM.
              HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

              Comment


                #22
                Originally posted by rprade View Post
                That should work, but would still have the original problem he was trying to resolve - that negative temperatures spoken are "dash 2.3 degrees", because TTS pronounces "-" as "dash".
                That is where the Replace function comes in.

                x = Replace(x,"-","minus ")

                It doesn't work with the replacement variable, because that structure isn't interpreted by the script. It should work fine if the DeviceString function works to insert the device string into the text that is assigned to x.
                Mike____________________________________________________________ __________________
                HS3 Pro Edition 3.0.0.548, NUC i3

                HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                Comment


                  #23
                  Originally posted by Uncle Michael View Post
                  That is where the Replace function comes in.

                  x = Replace(x,"-","minus ")

                  It doesn't work with the replacement variable, because that structure isn't interpreted by the script. It should work fine if the DeviceString function works to insert the device string into the text that is assigned to x.
                  Like I was saying, the hsDeviceString will likely return null, because the string is not populated on most devices. What Gogs needs is to be able to get $$DSR:xxxx: which is the Status Text, into the text string in a script. There is a call that will use a replacement variable, I just don't remember what it was. If we could find that and be able to populate the string with the status text, then your suggestion would work.

                  Someone posted the HS function within the last month, but I have not found it yet.
                  HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

                  Comment


                    #24
                    Originally posted by Uncle Michael View Post
                    Did you try this and it didn't work? What did you get? Were there any error messages?

                    x = "Good "& TimeOfDay() & ".. The time is " & myTime() & "..It is" & WeekdayName(DatePart("w", Date)) & MonthName(DatePart("m", Date))& ",,the" & myday() & "," & "and the current outside temperature is " & hs.DeviceString(408) & "but it feels like " & hs.DeviceString(418)
                    Just re-tried it and zilch, no errors just blanks
                    sigpic
                    A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                    Comment


                      #25
                      Originally posted by rprade View Post
                      [ATTACH]65726[/ATTACH]

                      Here is the Status Graphics page where it is selected to have 1 decimal place for the status text

                      [ATTACH]65727[/ATTACH]

                      Depending on how your device's value is set by the plug-in, it may have way too much precision for a spoken value. That is why you would truncate it or use hs.DeviceValue so that it is only the integer. All you need to do is look at the Advanced tab to see the real precision of your device.

                      I don't do scripting much, but I will see if I can figure something out.
                      I posted what was on the advanced page.
                      sigpic
                      A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                      Comment


                        #26
                        I found it. It was in a post Jon Simmons made to Gogs.

                        hs.ReplaceVariables("$$DSR:xxxx:")

                        It was in this thread from August.

                        Using that in a script should get the Status Text in the string so that the replace function will work.
                        HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

                        Comment


                          #27
                          Originally posted by Gogs View Post
                          I posted what was on the advanced page.
                          I didn't see it, but the post above shows how to get the Status Text into your string for processing. Then you wouldn't need to use the Value and truncate it.
                          HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

                          Comment


                            #28
                            Originally posted by rprade View Post
                            I found it. It was in a post Jon Simmons made to Gogs.

                            hs.ReplaceVariables("$$DSR:xxxx:")

                            It was in this thread from August.

                            Using that in a script should get the Status Text in the string so that the replace function will work.
                            Great find fom the Mistro Jonn, however, that is to get positions into readable and speable form, not to change the text.

                            Good research.
                            sigpic
                            A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                            Comment


                              #29
                              Originally posted by Gogs View Post
                              Great find fom the Mistro Jonn, however, that is to get positions into readable and speable form, not to change the text.

                              Good research.
                              No, but you would use it in the suggestion Michael gave you in post #19, putting the string in x. Instead of:

                              x = "Good "& TimeOfDay() & ".. The time is " & myTime() & "..It is" & WeekdayName(DatePart("w", Date)) & MonthName(DatePart("m", Date))& ",,the" & myday() & "," & "and the current outside temperature is " & hs.DeviceString(408) & "but it feels like " & hs.DeviceString(418)

                              It would be:

                              x = "Good "& TimeOfDay() & ".. The time is " & myTime() & "..It is" & WeekdayName(DatePart("w", Date)) & MonthName(DatePart("m", Date))& ",,the" & myday() & "," & "and the current outside temperature is " & hs.ReplaceVariables("$$DSR:408:") & "but it feels like " & hs.ReplaceVariables("$$DSR:418:")

                              Then after putting the string in x you would process x with:

                              x = Replace(x,"-","minus ")

                              then hs.speak (x, True, "Control:Livingroom")

                              Hopefully this makes sense - as I wrote above my scripting skills are at best, weak.

                              I think the original problem stemmed from the fact that HS2 allowed the direct use of replacement variables in scripting, but HS3 doesn't.

                              If you want to post the whole script this snippet was from:
                              Code:
                              sub main()
                              	Dim a
                              	Dim b
                              	Dim c
                              	Dim d
                                    Dim x
                              x = Replace(x,"-","minus ") 
                              hs.speak "Good "& TimeOfDay() & ".. The time is " & myTime() & "..It is" & WeekdayName(DatePart("w", Date)) & MonthName(DatePart("m", Date))& ",,the" &  myday() & "," & "and the current outside temperature is $$Dsr:408:.." & "," & "but it feels like $$Dsr:418: ..",TRUE,"Control:Livingroom"
                              we can probably fix it.
                              HS4 Pro, 4.2.19.16 Windows 10 pro, Supermicro LP Xeon

                              Comment


                                #30
                                Originally posted by rprade View Post
                                Like I was saying, the hsDeviceString will likely return null, because the string is not populated on most devices. What Gogs needs is to be able to get $$DSR:xxxx: which is the Status Text, into the text string in a script.
                                Good point. I was fixated on the data being in the device string. As you note, it probably isn't there, which is born out by Gordon's test which returns blank for the device string.

                                Gordon,
                                What does your temperature device Advanced tab look like? This is one of mine for reference:
                                Attached Files
                                Mike____________________________________________________________ __________________
                                HS3 Pro Edition 3.0.0.548, NUC i3

                                HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF | RFXCOM | Vantage Pro | Green-Eye | Edgeport/8 | Way2Call | Ecobee3 | EtherRain | Ubiquiti

                                Comment

                                Working...
                                X