Jump to content

SAPI voice to wave output


leecole
 Share

Recommended Posts

I want to create a message using a SAPI voice and save it as a wav file. I am trying to follow the Microsoft VB example: http://msdn2.microsoft.com/en-us/library/ms717065.aspx

but am having problems with the vb "FileStream.Open FileName, SSFMCreateForWrite, True" statement.

Here is my code. Any help?

Dim $Where = "C:\Sounds"
Dim $Voice = 3
Dim $Media = 0
Dim $File
Dim $Msg = InputBox("Message to be recorded","Msg: ")
DirCreate($Where)
$File=FileSaveDialog("Name",$Where,"Wave files (*.wav)")&".wav"
_TalkOBJ($Msg,$File,$Voice)
Exit 0

Func _TalkOBJ($s_text,$output,$s_voice = 3)
    Local Const $Done = 1
    Local $quite = 0
    Local $o_speech = ObjCreate ("SAPI.SpVoice")
    Local $o_file = ObjCreate ("SAPI.SpFileStream")
    $o_file.Open($output,"SSFMCreateForWrite")
    $o_speech.AudioOutputStream = $o_file
    Select
        Case $s_voice == 0
            Return
        Case $s_voice == 1
            $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mary", "Language=409").Item(0)
            TrayTip("Female Reader",$s_text,1)
        Case $s_voice == 2
            $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Mike", "Language=409").Item(0)
            TrayTip("Male Reader",$s_text,1)
        Case $s_voice == 3
            $o_speech.Voice = $o_speech.GetVoices("Name=Microsoft Sam", "Language=409").Item(0)
                        TrayTip("OldMan Reader",$s_text,1)
    EndSelect
;If Not $quite Then $o_speech.Speak ($s_text)
    If Not $quite Then 
        Do
            Sleep(250)
        Until $o_speech.Status.RunningState  = $Done
        $o_speech.Speak ($s_text)
    EndIf
    $o_file.Close
    $o_file = ""
    $o_speech = ""
    Sleep(1000)
;TrayTip("","",1)
EndFunc  ;==>_TalkOBJ

Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits

Link to comment
Share on other sites

_SpeakToWAV("TEST",@ScriptDir&"\respond.wav")

Func _SpeakToWAV($sText,$sFile)
    $ObjVoice=ObjCreate("Sapi.SpVoice")
    $ObjFile=ObjCreate("SAPI.SpFileStream.1")
    $objFile.Open($sFile,3)
    $objVoice.AudioOutputStream = $objFile
    $objVoice.Speak ($sText)
EndFunc

Credit goes to SolidSnake

Link to comment
Share on other sites

_SpeakToWAV("TEST",@ScriptDir&"\respond.wav")

Func _SpeakToWAV($sText,$sFile)
    $ObjVoice=ObjCreate("Sapi.SpVoice")
    $ObjFile=ObjCreate("SAPI.SpFileStream.1")
    $objFile.Open($sFile,3)
    $objVoice.AudioOutputStream = $objFile
    $objVoice.Speak ($sText)
EndFunc

Credit goes to SolidSnake

Thanks!!!

Talking Clockhttp://www.autoitscript.com/forum/index.php?showtopic=20751Talking Headlineshttp://www.autoitscript.com/forum/index.php?showtopic=20655Sometimes, I sits and thinkssometimes, I just sits

Link to comment
Share on other sites

I created one that would either convert a file to a SAPI sound file or whatever you typed into the text area.

You can find it here.<{POST_SNAPBACK}>

Spoiler

 

"...Yes, I am a criminal. My crime is that of curiosity. My crime is that of judging people by what they say and think, not what they look like.My crime is that of outsmarting you, something that you will never forgive me for." --The Mentor

"Mess with the best, die like the rest!!" -Hackers

"This above all to thine own self be true." -William Shakespeare

"Corruption is only as corrupted as the individual makes it out to be." -i386

 

style7,AutoIt.png

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...