Announcement

Collapse
No announcement yet.

How to determine when speech is concluded

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

    How to determine when speech is concluded

    I have a couple of events that need to be triggered before and after speech. I have been using Blade's BLSpeech's 'Before Speaking' and 'After Speaking' triggers and have had some success, but lately the 'After Speaking' trigger has not been working.

    Has anyone else had this problem, and if so come up with a solution?

    Thanks
    Don

    #2
    Not scripting and I don't know how well this works, but if you select "Speak Something" in an event the red airplane shows up and a check box lets you select "Wait for Speech to Finish."
    HomeSeer Version: HS4 Pro Edition 4.2.19.0 (Windows - Running as a Service)
    Home Assistant 2024.3
    Operating System: Microsoft Windows 11 Pro - Desktop
    Z-Wave Devices via two Z-Net G3s
    Zigbee Devices via RaspBee on RPi 3b+
    WiFi Devices via Internal Router.

    Enabled Plug-Ins
    AK GoogleCalendar 4.0.4.16,AK HomeAssistant 4.0.1.23,AK SmartDevice 4.0.5.1,AK Weather 4.0.5.181,AmbientWeather 3.0.1.9,Big6 3.44.0.0,BLBackup 2.0.64.0,BLGData 3.0.55.0,BLLock 3.0.39.0,BLUPS 2.0.26.0,Device History 4.5.1.1,EasyTrigger 3.0.0.76,Harmony Hub 4.0.14.0,HSBuddy 4.51.303.0,JowiHue 4.1.4.0,LG ThinQ 4.0.26.0,ONVIF Events 1.0.0.5,SDJ-Health 3.1.1.9,TPLinkSmartHome4 2022.12.30.0,UltraCID3 3.0.6681.34300,Z-Wave 4.1.3.0

    Comment


      #3
      Thanks, but as you noted, that doesn't really address my problem. Hopefully one of the heavyweights script guys will weigh in.
      Appreciate the response.
      Don

      Comment


        #4
        I understand your problem and i am dealing with it too. However i couldn't find a 100% correct solution.
        But i managed to come close. What i do is i account the number of letters in the string to be spoken.

        * i don't have access to the code at the moment but here's some pseudo-code

        This can be done in vbscript with len( "your string")
        To speak 6 letters it takes about 1000 miliseconds (1 second) so using delay( (len("your string") / 6) * 1000 ) after your hs.speak command will pause it long enough to hear the full message and then continue doing the other things that have to be done. Tweaking the 6 or the 1000 here for your situation

        - Bram

        Send from my Commodore VIC-20

        Ashai_Rey____________________________________________________________ ________________
        HS3 Pro 3.0.0.534
        PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

        Comment


          #5
          Ouch! Well, I'll give that a try.

          Thank you.
          Don

          Comment


            #6
            Try this:

            Create an event to run the first event, then this script:

            Code:
            Sub Main(ByVal Parm As Object)
            Dim sw As New System.Diagnostics.Stopwatch
                sw.Start()
                Do
                    If hs.IsSpeakerBusy Then sw.Restart()
                    If sw.ElapsedMilliseconds > 1000 Then Exit Do
                    hs.waitsecs(0.05)
                Loop
            End Sub
            (Make sure you tick, wait for script to finish in the event)

            Finally run the second event.

            Depending on any gaps in speaking, you may need to increase the 1000 to something higher.
            Jon

            Comment


              #7
              Just realized I didn't thank you for this bit of code. Thank you

              Appreciate both of your suggestions.

              Originally posted by jon00 View Post
              Try this:

              Create an event to run the first event, then this script:

              Code:
              Sub Main(ByVal Parm As Object)
              Dim sw As New System.Diagnostics.Stopwatch
              sw.Start()
              Do
              If hs.IsSpeakerBusy Then sw.Restart()
              If sw.ElapsedMilliseconds > 1000 Then Exit Do
              hs.waitsecs(0.05)
              Loop
              End Sub
              (Make sure you tick, wait for script to finish in the event)

              Finally run the second event.

              Depending on any gaps in speaking, you may need to increase the 1000 to something higher.
              Don

              Comment


                #8
                Hello Jon;

                Struggling with this a bit. Do I need to import System.Diagnostics in my Scripting References in the settings.ini file?

                The error message in my log says something like 'system.core doesn't contain any public member or cannot be found'.
                I commented everything up to the sw As New... to try and see where the script crashed.

                Code:
                Imports System.Diagnostics
                Imports System.Threading
                
                Sub Main(byVal sText As String)
                
                Dim sw As New System.Diagnostics.Stopwatch
                
                REM sw.Start()
                REM Do
                REM If hs.IsSpeakerBusy Then sw.Restart()
                REM If sw.ElapsedMilliseconds > 1000 Then Exit Do
                REM hs.waitsecs(0.05)
                REM LogIt("Waiting",2)
                REM Loop
                Exit Sub
                Thanks
                Don

                Comment


                  #9
                  I think Exit sub should be End Sub?
                  Jon

                  Comment


                    #10
                    Yep. Thanks for catching that. Will bungle on.

                    Don

                    Comment

                    Working...
                    X