文本朗读如何不等待[已解决,感谢]
本帖最后由 lin6051 于 2012-5-3 12:50 编辑dim $v="hou hou share she, ten ten soung shang. "
_TalkOBJ($v)
msgbox(0,"提示","")
Func _TalkOBJ($s_text)
Local $o_speech = ObjCreate("SAPI.SpVoice")
$o_speech.Speak($s_text)
$o_speech = ""
EndFunc
搜索了一下,都类似上面 的 脚本, 这个要 等朗读完成后 才能执行下一行命令
有没有方法可以不等待它朗读完就执行下一行命令? 分为两个EXE 本帖最后由 komaau3 于 2012-4-30 01:10 编辑
回复 1# lin6051
朗读标志设为1就行了,
$o_speech.Speak($s_text, 1)
其他标记你自己研究吧Enum SpeechVoiceSpeakFlags
'SpVoice Flags
SVSFDefault = 0
SVSFlagsAsync = 1
SVSFPurgeBeforeSpeak = 2
SVSFIsFilename = 4
SVSFIsXML = 8
SVSFIsNotXML = 16
SVSFPersistXML = 32
'Normalizer Flags
SVSFNLPSpeakPunc = 64
'TTS Format
SVSFParseSapi =
SVSFParseSsml =
SVSFParseAutoDetect =
'Masks
SVSFNLPMask = 64
SVSFParseMask =
SVSFVoiceMask = 127
SVSFUnusedFlags = -128
End Enum dim $v="hou hou share she, ten ten soung shang. "
_TalkOBJ($v)
msgbox(0,"提示","")
Func _TalkOBJ($s_text)
Local $o_speech = ObjCreate("SAPI.SpVoice")
$o_speech.Speak($s_text,1)
$o_speech = ""
EndFunc
没用啊 回复 3# komaau3
1,11 都跳过朗读了 本帖最后由 komaau3 于 2012-4-30 15:22 编辑
回复 4# lin6051
;异步朗读,
Local $text="you should give me some talk time but not kill me when I just want to read !will you ?"
Local $V = ObjCreate("SAPI.SpVoice")
$V.Speak($text,1)
ConsoleWrite("see, i'm reading now..." & @CRLF)
$V.WaitUntilDone (-1);你可以做任何事情,但不是立即退出或把对象给注销掉
ConsoleWrite('sure... i killed you , i should not set $o_speech=none , ' & @CRLF)
;同步,不会及时返回
Local $text="don't cut in until I finished reading these texts , ok ?"
Local $V = ObjCreate("SAPI.SpVoice")
$V.Speak($text,0)
ConsoleWrite('sure...' & @CRLF)
本帖最后由 komaau3 于 2012-4-30 17:36 编辑
回复 5# lin6051
同样 为了更可靠的实现功能部署 我们可以使用event事件来监控朗读是否结束
示例:
;异步朗读,
Local $text="hoo , i also support event events."
Local $V = ObjCreate("SAPI.SpVoice")
ObjEvent($V, '_SpVoice_')
$V.Speak($text,1)
While 1
Sleep(100)
WEnd
Func _SpVoice_StartStream()
MsgBox(0,0,'朗读开始')
EndFunc
Func _SpVoice_EndStream()
MsgBox(0,0,'朗读结束')
EndFunc
还能朗读呀?厉害还会 7楼的这个如何加入重复朗读,我怎么改也只朗读一遍。 7楼的这个如何加入重复朗读,我怎么改也只朗读一遍。
页:
[1]