Announcement

Collapse
No announcement yet.

VB6 DirectSS and WMP Mute

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

  • VB6 DirectSS and WMP Mute

    I think I am in correct forum lol.

    Looking for some info for my personal CarPuter

    Written in VB6 and Using DirectSS for Voice

    .Speak " Speaking this text"


    How would I go about having Windows Media Player Mute during Speak ?

  • #2
    Any of you Front end coders have any suggestions?

    I am thinking I need to make a function with the
    spSpeak.speak
    and
    WMP.Settings.Mute = true

    Code:
    Private Function funSpeak()
    dim speak as ?
    WMP.Settings.Mute = true
    spSpeak.Speak
    WMP.Settings.Mute = False
    End Function
    Then everywhere in my code I have spSpeak.Speak "speak this"
    I would just call the function

    Speak() "Speak This? "


    You think I am on correct track here?

    Comment


    • #3
      Since the .Speak text is always different, I am not sure how to make a function for it?

      speak = spSpeak.Speak + the text that needed?

      Hmmm
      So I guess I could use an ini file with all the specific sentences in it,
      But still not sure how to do this one line??

      spSpeak.Speak <- What after here?

      Comment


      • #4
        I am using VB6 for my front end as well and plan to use voice recognition with speech (SAPI 4). The problem I had was when I sent a .speak, the VR heard it too and got "confused".

        The challenge is when a .speak is sent the program doesn't wait for the speech to finish, it keeps going. So in the piece of code you posted the WMP would unmute before the voise was done speaking.

        I have to get back to it, but I believe the solution is to set up a TTS event (speakingdone) that will unmute the WMP when it is done speaking. So you would set up a speakingdone event where the WMP unmutes; then when you send a speak command you would mute the WMP audio, send the .speak, and when the speak is done it will call the event and unmute the WMP.

        Have you tried any of the non-Microsoft voices? The AT&T "Natural" ones are quite a bit better than what MS supplies. Also which SAPI version are you using, 5 or 4? I've found 4 to be better to work with.
        Last edited by CanuckMark; 02-08-2011, 02:38 PM.

        Comment


        • #5
          I am using 4 as well,
          I was thinking to use a pause in the function but ur Idea sounds much better.

          I am also wanting to control unwanted activation as well.
          Right now I just have a special command word and long sentences, but am wondering if 2 instances of the voice recognition might work.


          Eg;
          One instant of voice recognition, with only ONE word, which in turn would enable the second to start listening?

          But that may slow app down way too much?

          Comment


          • #6
            To solve that problem I was planning to mute the microphone whenever TTS was speaking (then have it unmute the mic when TTS is done). Basically like what you're trying to do with the WMP (same process of events anyway). That way the VR simply can't hear the speak. My gues is that would be easier than an extra instance of VR.

            Comment


            • #7
              True, but I am thinking about regular conversation and music in the back ground.

              As for it here speak, I was making the Speak have different terms than the VR menu
              example, If I say "goto Naviagtion" then I make sure the Speak doesnt ever say Navigation, I may have it say Nav Panel etc etc.

              Muting the Mic would be good though!

              Comment


              • #8
                I don't know about the VB6 API, but in VB.NET, waiting for variable-length speech to finish is pretty easy. I have to do it in my FrontEnd.

                My solution: When speech is started, mute WMP and create a timer to poll the SpeechState until speech has stopped. When it has stopped, restore volume and kill the timer.

                The code in the timer tick event is something like this in my front end:
                If SpechObj.State <> System.Speech.Synthesis.SynthesizerState.Speaking Then
                Timer.Stop
                RestoreVolume
                End If

                Again, like I said, I don't know the VB6 Speech API. I had to abandon VB6 a while ago. But it's probably something similar, but with more API involved.

                Comment


                • #9
                  Yup, that's another approach. Originally I was looking at that variable, but then I found the .speakingdone event and was sold. It made things work a lot more efficiently.

                  Comment


                  • #10
                    Originally posted by CanuckMark View Post
                    Yup, that's another approach. Originally I was looking at that variable, but then I found the .speakingdone event and was sold. It made things work a lot more efficiently.
                    Somehow I never even noticed that event existed. Nice!

                    So yeah, use the event if it's exposed in VB6. Not a timer.

                    Comment


                    • #11
                      I am not seeing this in vb6
                      ' If spkSpeak.speakingdone = False Then MsgBox "error"

                      I do see thiese but they do not seem to do anything

                      spkSpeak.AudioPause
                      spkSpeak.Speak sText
                      spkSpeak.AudioResume

                      ---------- Post added at 03:50 PM ---------- Previous post was at 03:15 PM ----------

                      Here is my temp solution, I leave some commented lines there so you can see some of what I have tried.

                      Code:
                      Public Enum SentenceEnum
                         say_IgnitionOff
                         say_IgnitionOn
                         say_AccOn
                         say_AccOff
                         say_Access
                      
                      
                      
                      ' etc
                      End Enum
                      
                      Public Function SayThis(SayWhat As SentenceEnum) As Boolean
                       '  ... any code needed to prepare speaking
                      
                         Dim sText As String
                         Select Case SayWhat
                         Case say_IgnitionOff
                              sText = "Turning Ignition Off"
                         Case say_IgnitionOn
                              sText = "Turning Ignition On"
                        ' Case say_AccOnAlready
                              sText = "Accessories is already On"
                         Case say_AccOn
                              sText = "Turning Accesories On"
                         Case say_Access
                              sText = "Authorization is needed to continue"
                      
                              
                         '.... other case statements
                         End Select
                         WM.Settings.volume = 0
                        ' spkSpeak.Speaking
                      'spkSpeak.AudioPause
                         spkSpeak.Speak sText
                       'If spkSpeak.Speaking = True Then MsgBox "error i bet"
                      'spkSpeak.AudioResume
                      Attente (10900)
                      WM.Settings.volume = lblVolume.Caption
                       '  ... any code needed after speaking
                         ' set your return value to true or false
                      End Function
                      
                      
                      Public Sub Attente(ByVal MilsecToWait As Long)
                          Dim lngEndingTime As Long
                          lngEndingTime = GetTickCount() + (MilsecToWait)
                          Do While GetTickCount() < lngEndingTime
                              DoEvents
                          Loop
                      End Sub
                      Last edited by planethax; 02-14-2011, 03:20 PM.

                      Comment


                      • #12
                        .speakingdone is not a property, it is an event. Under the code window, select the TTS control in the top-left dropdown (in your case it is called spkSpeak, the "Text To Speech" control). Then look at the list in the right dropdown; you'll find a whole bunch of events that are automatically called when different things happen. SpeakingDone and SpeakingStarted are the two obvious useable ones.

                        When you select SpeakingDone from that list, you'll get this:

                        Code:
                        Private Sub spkSpeak_SpeakingDone()
                        
                        End Sub
                        That sub will call when the voice is done speaking...drop your mute command in there and you're done.

                        EDIT: I took another look at this and it appears we were working with two different versions of the text-to-speech OCX - my SAPI4 installed two different OCXs. I was looking at the events of the TextToSpeech one and you seem to be using the DirectSS one. The good news is it still works, but the event is called AudioStop instead of SpeakingDone. Same thing, it's an event - set up the sub in the code. I just tried it - I sent some speak to it and the instant it finished speaking it called the AudioStop event.

                        Something like this:

                        Code:
                        Private Sub Command1_Click()
                            ' MUTE THE WMP HERE
                            DirectSS1.Speak "hello hello hello hello hello"
                        End Sub
                        
                        Private Sub DirectSS1_AudioStop(ByVal hi As Long, ByVal lo As Long)
                            ' UNMUTE THE WMP HERE
                        End Sub
                        Last edited by CanuckMark; 02-15-2011, 09:03 PM.

                        Comment

                        Working...
                        X