Text to Speech on Windows 7?
Ok, so I just remember one of the 'old' days program, a two line one, which was fascinating when I was younger. The code is
Code:
Private Sub Command1_Click()
Set TtS = CreateObject("SAPI.spVoice")
TtS.speak Text1
End Sub
Pretty simple, worked fine on XP (my friend, to whom I mailed it, claims to) but throws just abrupt silence on my Windows 7. I know that this is because I am missing Speech Libraries or the required Control. I have been searching from morning and all I could get to was, "Microsoft Direct Text-To-Speech control" is what I need. And the hunt for it has come to nothing upto now, I couldn't just locate that 'part' of the download. I go to Microsoft speech sdk, there is 5.1 which has about 5 download, one of which weighs 300+ and the rest are under 100. Are these what I should be downloading? OR should I get SDK 11? Which is within 5 all together? I am totally clueless, or do I need 5.1 + 11 to get it working on Windows 7? Or is there an alternative to this?
Could anyone help me with this? Thanks in advance.
Re: Text to Speech on Windows 7?
You probably won't need to download anything to get the Microsoft Speech API to work on your Windows 7 system. Just set a reference to the "Microsoft Speech Object Library" in your project. Here are the documentations for the SpVoice object, the Speak method and the Volume property.
Re: Text to Speech on Windows 7?
Thank you Bonnie. :)
My program works fine on my Laptop, which also runs on Windows 7, but doesn't on PC. Will check out those links now.
Re: Text to Speech on Windows 7?
I set the Reference to it, hope it is the one from Project -> References, but that doesn't work either. :(
I get the delay, I mean the buttons aren't working and text box cannot be edited for a little while, say 1 second, in other words, form behaves as is it IS reading, but it isn't. I don't hear any vocal output. What could be wrong?
Re: Text to Speech on Windows 7?
Quote:
Originally Posted by
Immanuel
I set the Reference to it, hope it is the one from Project -> References, but that doesn't work either. :(
Can you post a screenshot of your References dialog box?
Quote:
Originally Posted by
Immanuel
I get the delay, I mean the buttons aren't working and text box cannot be edited for a little while, say 1 second, in other words, form behaves as is it IS reading, but it isn't. I don't hear any vocal output. What could be wrong?
Have you set the Volume property to max before invoking the Speak method? Can you also post the code you're using?
Re: Text to Speech on Windows 7?
Code:
Private Sub btn1_Click()
Set TtS = CreateObject("SAPI.spVoice")
'TtS.Volume = 100
TtS.speak Text1
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
That is all, nothing fancy, I just want to see if it can read the Text. Doesn't throw error. Neither does it read, I tried that volume control, the one you gave link to was for SAPI5.4, it has the object from SpeechLib.Spvoice, I doubt that it is the same as SAPI5.spvoice, either way, trying Volume paramter on the object didn't seem to work.
BTW, the code, without Volume (commented above) works fine on my friend's Windows 8 Laptop too. :/
Re: Text to Speech on Windows 7?
There are many kinds of programs that cannot be developed using XP any more.
In the post-XP era lots of things have changed. The audio subsystem in Windows is quite different for example. So to develop SAPI programs for post-XP systems you may need a newer version of the SDK and develop on Vista or later.
Microsoft Speech Platform - Software Development Kit (SDK) (Version 11) has the required downloads for modern versions of Windows.
See Microsoft Speech Platform Software Development Kit (SDK) version 11.0 – Release Notes which says:
Quote:
Windows XP support for SDK tools. The Grammar Development Tools (with the exception of PrepareGrammar.exe) are now supported on computers running Windows XP, but only for some providers. Using the "local" provider is not supported on Windows XP. See Speech Recognition Engine Configuration File Settings for more information.
and:
Quote:
In addition, Windows XP service Pack 3, has limited support under the following conditions:
- x86 only
- The SDK tools on Windows XP will only work when configured against a hosted (non-local) recognizer
- Note: In addition, SAPI is not supported on Windows XP
While the Version 11 SDK only provides limited support for XP SP3 (and none at all for SAPI) it may be possible that a SAPI program written and compiled for XP on XP might still work on Windows 7 as long as you deploy the modern versions of the redistributable libraries.
Microsoft Speech Platform - Runtime (Version 11)
Note that both the SDK and the Runtime come in x86 and x64 variations. I don't think that VB6 can work with the x64 variety at all, and have not tested whether the x86 variety will install into a 64-bit Windows system.
Re: Text to Speech on Windows 7?
Quote:
Originally Posted by
Immanuel
That is all, nothing fancy, I just want to see if it can read the Text. Doesn't throw error. Neither does it read, I tried that volume control, the one you gave link to was for SAPI5.4, it has the object from SpeechLib.Spvoice, I doubt that it is the same as SAPI5.spvoice, either way, trying Volume paramter on the object didn't seem to work.
BTW, the code, without Volume (commented above) works fine on my friend's Windows 8 Laptop too. :/
This works fine for me on Windows 7.
vb Code:
Option Explicit
Dim Tts As SpVoice
Private Sub btn1_Click()
Set Tts = CreateObject("SAPI.spVoice")
'TtS.Volume = 100
Tts.speak Text1.Text
End Sub
Private Sub Form_Load()
Text1.Text = ""
End Sub
Stupid question but are you actually putting text in the textbox before you click the button?
Edit:
The above code was tested with Microsoft Speech SDK 5.1.
Re: Text to Speech on Windows 7?
Yeah, I enter the text into the TextBox, say "Hello" and the click button, the form is unresponsive for a particular time interval as if its reading it, but no vocal output.
Just out of curiosity, I downloaded Microsoft Talk It, I think it'd work on the same principle, it does EXACTLY the same, unresponsive unless I press Stop Talking, behaves as if it is talking. I am pretty sure that it should throw error if there is no Speech Library files (SAPI5) right? Or would that be the problem that I face?
I just now turned on narrator from Ease of Access / Accessibility and it also maintains a pin drop silence. :/ As I mentioned in OP, I know that this isn't code related (atleast I feel that way) but what EXACT module/SDK should I be downloading? The redistributables come as ".MSM" files, Googling said that it requires some Installer to be made and stuff, so what should I venture into next?
2 Attachment(s)
Re: Text to Speech on Windows 7?
I'm not sure what the problem might be either.
This one runs fine on XP SP3, Vista SP2, and Win7 SP1 here. Compiled on Vista and I only copied the EXE to the other systems to test there.
The only difference is that on my Vista machines I get three voice choices though on the others there is only one to choose from. The LH voices may have installed with some scanner software or something.
Code:
Option Explicit
Private WithEvents SPVoice As SpeechLib.SPVoice
Private Sub EnableUI(ByVal Enabled As Boolean)
List1.Enabled = Enabled
Text1.Enabled = Enabled
Command1.Enabled = Enabled
End Sub
Private Sub Command1_Click()
EnableUI False
Set SPVoice.Voice = SPVoice.GetVoices().Item(List1.ListIndex)
SPVoice.Speak Trim$(Text1.Text), SVSFlagsAsync
End Sub
Private Sub Form_Load()
Dim Token As SpeechLib.SpObjectToken
On Error Resume Next
Set SPVoice = New SpeechLib.SPVoice
If Err Then
Err.Clear
MsgBox "SAPI not found"
Unload Me
End If
On Error GoTo 0
SPVoice.EventInterests = SVEEndInputStream
For Each Token In SPVoice.GetVoices()
List1.AddItem Token.GetDescription()
Next
List1.ListIndex = 0
Text1_Change
End Sub
Private Sub Text1_Change()
Command1.Enabled = Len(Trim$(Text1.Text)) > 0
End Sub
Private Sub SPVoice_EndStream(ByVal StreamNumber As Long, ByVal StreamPosition As Variant)
EnableUI True
End Sub
Re: Text to Speech on Windows 7?
Merge modues (MSMs) are used for including dependencies in a Windows Installer package (.MSI) for people to use to install your program.
The newer versions (for post-XP Windows versions) also come as a standalone installer (MSI) so you don't have to build your own, but the ancient version 5.x stuff for XP seems to only come as MSMs.
You'd need Visual Studio 6.0 Installer 1.1 which used to be a free download for VS6/VB6 licensees, but the downloads are no longer available from Microsoft (two files).
Re: Text to Speech on Windows 7?
If you need the Speech Runtime for a Windows 7 machine look at the second link in post #7 above.
Re: Text to Speech on Windows 7?
I got the Speech Runtime files, upon Install, it asked to repair, which means I already had it. So I uninstalled it and then reinstalled it, still doesn't work. Your sample project loads up fine, does the same though, Mary and Mike throw up errors "Cannot create object" then other two, Sample TTS and Anna "seem" to work, but no vocal output. :/ This is more and more developing into a chase after the wind.
Edit:
I downloaded another Free TTS from internet "Ultra Hal" it also does the same, shows progress bar as though its reading, but still I don't hear any output.
BTW I hope that the Vocal output would get cancelled out on 5.1 Surround Sound System. My desktop has it, the vocal should be on Central Speaker IIRC, and the voice of other games (5.1 supported) and such works fine.
Re: Text to Speech on Windows 7?
Not sure if this video will be of any help or not?
Re: Text to Speech on Windows 7?
Thanks for the help, but that is just another TtS, with CFS having pulled out of Speakonia, I had to get it from CNET, the Speakonia itself doesn't work, just like the other TTS I mentioned, and this also didn't add the voice or speech functionality to this simple code in my system yet.
Re: Text to Speech on Windows 7?
Quote:
Originally Posted by
Immanuel
BTW I hope that the Vocal output would get cancelled out on 5.1 Surround Sound System. My desktop has it, the vocal should be on Central Speaker IIRC, and the voice of other games (5.1 supported) and such works fine.
Not sure about this, but if your system has another audio output device, then you could try selecting that via the AudioOutput property.