vb语音读文章方法.pdfVIP

  • 23
  • 0
  • 约1.54千字
  • 约 2页
  • 2022-07-26 发布于福建
  • 举报
vb 语 音 读 文 章 方 法 Dim WithEvents Voice As SpVoice Private Sub Combo1_Click() Voice.Speak vbNullString, 2 Set Voice.Voice = Voice.GetVoices().Item(Combo1.ListIndex) End Sub Private Sub Command1_Click() Set ReadDoc = WebBrowser1.Document.getElementById(content) ReaderTxt = ReadDoc.innerText Voice.Speak ReaderTxt, 1 End Sub Private Sub Form_Load() Set Voice = New SpVoice Dim Token As ISpeechObjectToken For Each Token In Voice.GetVoices Combo1.AddItem (Token.GetDescription()) Next Combo1.ListIndex = Combo1.ListCount - 1 Set Voice.Voice = Voice.GetVoices().Item(Combo1.ListIndex) 初 始 化 语 音 库 WebBrowser1.Navigate (App.Path /Content.html) End Sub Private Sub Voice_Word(ByVal StreamNumber As Long, ByVal StreamPosition As Variant, ByVal CharacterPosition As Long, ByVal Length As Long) On Error Resume Next sp = CharacterPosition ep = Length Set box = WebBrowser1.Document.getElementById(content) Set rng = WebBrowser1.Document.body.createTextRange() rng.moveToElementText (box) sp = Int(sp) ep = Int(ep) rng.collapse (True) rng.moveEnd character, sp + ep rng.moveStart character, sp rng.Select 问 题 : 阅 读 Webbrowser 控 件 里 的 内 容 时 , 如 果 一 遇 到 换 行 高 亮 就 不 准 , 比 当 前 朗 读 的 内 容 多 。 具 体 的 点 “朗 读 演 示 ”就 明 白 了 。 求 高 手 解 决 !谢 谢 ! DoEvents End Sub

文档评论(0)

1亿VIP精品文档

相关文档