|
-
Feb 7th, 2011, 06:03 PM
#1
Thread Starter
Fanatic Member
Help with writting a Function
Looking for some info for my personal CarPuter
DirectSS for Voice (Xvoice.dll)
Usage
.Speak " Speaking this text"
How would I go about having Windows Media Player Mute during Speak ?
Last edited by planethax; Feb 8th, 2011 at 01:50 PM.
-
Feb 7th, 2011, 09:01 PM
#2
Thread Starter
Fanatic Member
Re: Muting WMP during DirectSS Speak
So 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?
-
Feb 8th, 2011, 11:19 AM
#3
Thread Starter
Fanatic Member
Re: Muting WMP during DirectSS Speak
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?
-
Feb 8th, 2011, 01:50 PM
#4
Thread Starter
Fanatic Member
Re: Muting WMP during DirectSS Speak
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?
-
Feb 8th, 2011, 05:27 PM
#5
Re: Help with writting a Function
Not sure what you are after, but a simple function looks like...
Code:
' sample call: SayThis "Hello World"
Public Function SayThis(WhatToSpeak As String) As Boolean
' any code needed before speaking
sp.Speak WhatToSpeak
' any code needed after speaking
' return true if successful else false
End Function
More details or real code may be helpful?
-
Feb 8th, 2011, 08:09 PM
#6
Thread Starter
Fanatic Member
Re: Help with writting a Function
It is the "What to speak" I am not sure how to do.
Project Speaks different things at different times,
Example, In a Case
Code:
Case "STACY POWER DOWN"
spkSpeak.Speak "Preparing to Power Down"
Attente 1000
' btnHib_Click
cmdHibernate_Click
Case "ENGINE DATA"
btnData_Click
spkSpeak.Speak "Going to O B D Panel"
but they are not just in the case
another spot
Code:
Private Function AccessoriesOn()
Attente (50)
funAsk
Attente (50)
If fStatus(0).BackColor = &HFF& Then
btnAccessories_Click
spkSpeak.Speak "Turning Accesories On"
Else
spkSpeak.Speak "Accessories is already On"
End If
End Function
Private Function IgnitionOn()
Attente (50)
funAsk
Attente (50)
If fStatus(0).BackColor = &HFF& Then
btnIgn.Picture = ilButtons.ListImages(15).Picture
btnAccessories.Picture = ilButtons.ListImages(18).Picture
spkSpeak.Speak "Turning Ignition On"
MSComm1.Output = "01+//"
Attente (50)
funAsk
MSComm1.Output = "02+//"
Attente (50)
funAsk ""
Else
spkSpeak.Speak "Ignition is already On"
End If
End Function
Private Function IgnitionOff()
Attente (50)
funAsk
Attente (50)
If fStatus(0).BackColor = &HC000& Then
btnIgn.Picture = ilButtons.ListImages(13).Picture
btnAccessories.Picture = ilButtons.ListImages(17).Picture
spkSpeak.Speak "Turning Ignition Off"
MSComm1.Output = "01-//"
Attente (50)
funAsk
MSComm1.Output = "02-//"
Attente (50)
funAsk
Else
spkSpeak.Speak "Ignition is already Off"
End If
End Function
Or
Code:
Private Sub btnIgn_Click()
If btnIgn.Picture = ilButtons.ListImages(13).Picture = True Then
btnIgn.Picture = ilButtons.ListImages(15).Picture
btnAccessories.Picture = ilButtons.ListImages(18).Picture
spkSpeak.Speak "Turning Ignition On"
MSComm1.Output = "01+//"
Attente (50)
funAsk
MSComm1.Output = "02+//"
Attente (50)
funAsk
Else
btnIgn.Picture = ilButtons.ListImages(13).Picture
btnAccessories.Picture = ilButtons.ListImages(17).Picture
spkSpeak.Speak "Turning Ignition Off"
MSComm1.Output = "01-//"
Attente (50)
funAsk
MSComm1.Output = "02-//"
Attente (50)
funAsk
End If
End Sub
So instead of having
Code:
spkSpeak.Speak "Turning Ignition Off"
I am thinking to have a Function (funSpeak) where I mute the Media player before speak then Unmute after
So
Code:
Private Sub
funSpeak = "Turning Ignition Off"
End Sub
Not sure if I explain well enough?
-
Feb 8th, 2011, 10:04 PM
#7
Re: Help with writting a Function
You are using the same sentences in several places? You may want to look at using a resource file and its string table or an string array of "Sentences". Either way, instead of hardcoding the sentences in all your routines; you'd reference the array item or LoadResString() from the resource file.
Another option could be to add your strings to your function and a Select Case to choose the words. Example:
Code:
' in your declarations section
Public Enum SentenceEnum
say_IgnitionOff
say_IgnitionOn
say_AccOn
say_AccOff
' 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"
'.... other case statements
End Select
spkSpeak sText
... any code needed after speaking
' set your return value to true or false
End Function
' sample call....
Private Function AccessoriesOn()
Attente (50)
funAsk
Attente (50)
If fStatus(0).BackColor = &HFF& Then
btnAccessories_Click
SayThis say_AccOn
Else
SayThis say_AccOnAlready
End If
End Function
If the last example is used, your SayThis() function will be the only place your strings are hardcoded. But you'll need to ensure you add a SentenceEnum value for each different sentence you want to speak
-
Feb 8th, 2011, 10:19 PM
#8
Thread Starter
Fanatic Member
Re: Help with writting a Function
Well I like the idea of using a resource file jus because it is something I should learn, though for starters putting all sentences in a case in the functions seems like a great way to go as well.
So generally I had
spSpeak (name of my DirectSS control
tell it to Speak spSpeak.Speak "Text to speak"
Now using Select Case
how would I call this?
example I want it to say say "Turning Ignition Off"
SayWhat (say_IgnitionOff)
or just
say_IgnitionOff
I am starting to get it, just not quite there.
(Though I know 100 times more now than 2 weeks ago thanx to everyone here!!!! )
-
Feb 8th, 2011, 10:21 PM
#9
Re: Help with writting a Function
SayThis say_IgnitionOff. Replace SayThis with whatever your function name is. By using an Enumeration, you'll get intellisense too.
Note that if the ENUM is in your form, make it Private or to keep it Public, move it to a module.
-
Feb 8th, 2011, 10:30 PM
#10
Thread Starter
Fanatic Member
Re: Help with writting a Function
THANX, one more question lol
I just did a Google for
VB6 Enumeration intellisense but didnt find a good explanation, just a pile questions.
I have NO idea what either are referring to, can ya point me to an easy to understand explanation?
I generally find Msdn to be over complicated and over my head
-
Feb 8th, 2011, 10:34 PM
#11
Re: Help with writting a Function
Try playing with the example.
If you type the function name, using the above example: SayThis
Then hit a space
You'll get the list of enumeration values to choose from. That is intellisense
Similar to this if you typed it in a form: Me.Enabled =
Then after you hit the equal sign, you'd get a drop down of options (similar to an enumeration)
Edited:
FYI: Intellisense is more than that though; it'll finish commands for you, fix some things
Example, type this in VB: Endif
If you then hit enter, VB will fix it for you so it reads: End If
If you didn't want to type out a complete property name, intellisense will help there too.
Example: Type this in VB: Me.Win
You'll get a drop down of options & simply pressing the tab key will finish it so it reads: Me.WindowState
I must admit that I abuse the heck out of intellisense . I never type End If any more; always type endif & enter
Last but not least for .Net users, VS2010 has code snippet intellisense. Now that sounds cool.
Last edited by LaVolpe; Feb 8th, 2011 at 10:51 PM.
-
Feb 8th, 2011, 10:40 PM
#12
Thread Starter
Fanatic Member
Re: Help with writting a Function
Ahhhhh
I get it!
Thanx!!!!!
Wish I could give more Rep but say I have to spread around!!!
I will work on implementing this tonight and in the morning!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|