vb微软tts文字转语音(语音播报)

Public Function 文字转语音(ByVal 文本内容 As String, Optional ByVal 音量 As Long = 100, Optional ByVal 语速 As Long = 0, Optional ByVal 语音引擎名字 As String = "VW Hui")    
Dim objVoice As Object    
Dim colVoice As Object    
Dim i As Long, cnVoice As Long, enVoice As Long    
Set objVoice = CreateObject("SAPI.SpVoice")    
Set colVoice = objVoice.GetVoices() '获得语音引擎集合    
objVoice.Volume = 音量 '设置音量,0到100,数字越大音量越大    
objVoice.Rate = 语速 '语音速度   
 '得到所需语音引擎的编号    
cnVoice = 0    For i = 0 To colVoice.Count - 1 
'选择语音引擎        
'Debug.Print colVoice(i).ID        
If Right(colVoice(i).ID, Len(语音引擎名字)) = 语音引擎名字 Then 
cnVoice = i    
Next    
Set objVoice.Voice = colVoice.Item(cnVoice) '设置语音引擎 
objVoice.Speak 文本内容    
Set objVoice = Nothing    
Set colVoice = Nothing
End Function

原文链接:https://www.juziyu.cn/451.html,转载请注明出处。

0
封面图

评论0

没有账号? 注册  忘记密码?

社交账号快速登录

微信扫一扫关注
如已关注,请回复“登录”二字获取验证码