|
Post by Guilect on May 8, 2008 19:03:12 GMT -5
This works on my Windows XP box. I am not sure what the requirements are. I have some other text-to-speech stuff on my machine and maybe they have loaded some required software already.
If it works on Windows XP and up, this would be a nice addition to a game.
Give it a try and let me know what your results and operating system is.
Option Explicit
Const SVSFlagsAsync = 1 const SVSFPurgeBeforeSpeak = 2
Dim Speech
CreateObjects Main DestroyObjects
Sub Main Dim sText sText = InputBox("Enter the text you want the computer to say", "Text2Speech") sText = Trim(sText) If sText <> "" Then SpeakText sText End If End Sub
Sub SpeakText(sText) On Error Resume Next Speech.Speak sText, SVSFlagsAsync + SVSFPurgeBeforeSpeak Do Sleep 100 Loop Until Speech.WaitUntilDone(10) End Sub
Sub StopSpeaking() On Error Resume Next Speech.Speak vbNullString, SVSFPurgeBeforeSpeak Set Speech = Nothing End Sub
Sub CreateObjects Set Speech = CreateObject("SAPI.SpVoice") End Sub
Sub DestroyObjects Set Speech = Nothing End Sub
|
|
|
Post by matthew on May 8, 2008 21:59:57 GMT -5
I can confirm that it works on Vista.
|
|
|
Post by u9 on May 10, 2008 5:51:14 GMT -5
work on xp too
|
|