如何在VB.NET中创建用于将语音转换为文本的代码? [英] How do I make a code in VB.NET for converting speech to text?

查看:233
本文介绍了如何在VB.NET中创建用于将语音转换为文本的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 Public Class Form1 
Private Sub Button1_Click(sender As Object,e As EventArgs)Handles Button1.Click
Dim Speech

Speech = CreateObject( sapi.spvoice)

Speech.Speak(欢迎)

Speech.Speak(TextBox1.Text)
结束次级
结束班级





我的尝试:



 dim conn As String =Data source = test; initial catalog = test; user id = test; password = test
dim dap As SqlDataAdapter
Dim lsqry as string = select * from test
dim dstest = New DataSet
dap = New SqlDataAdapter(lsqry,conn)
dap.Fill(dstest)

解决方案

使用 SpeechSynthesizer [ ^ ]来自 System.Speech.Synthesis [ ^ ]命名空间。



添加对 System.Speech 程序集的引用,使用:

 使用语音 As   System.Speech.Synthesis.SpeechSynthesizer()
Speech.SetOutputToDefaultAudioDevice()
Speech.Speak( 欢迎
Speech.Speak(TextBox1.Text)
结束 使用






NB :您的标题建议您想要语音识别,但问题中的代码块表明您需要语音ch synthesis。



如果你想将语音转换成文本而不是文本到语音,你需要使用System.Speech.Recongition [ ^ ]命名空间。



语音识别 - 使用.NET桌面应用程序进行语音识别 [ ^ ]

你试过的是一些SQL。它与语音API无关。请查看 vb.net sapi - Google搜索 [ ^ ]


Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim Speech
 
        Speech = CreateObject("sapi.spvoice")
 
        Speech.Speak("Welcome")
 
        Speech.Speak(TextBox1.Text)
    End Sub
End Class



What I have tried:

dim conn As String = "Data source=test;initial catalog=test;user id=test;password=test"
dim dap As SqlDataAdapter
Dim lsqry as string="select * from test"
dim dstest = New DataSet
dap = New SqlDataAdapter(lsqry , conn)
dap.Fill(dstest)

解决方案

Use the SpeechSynthesizer[^] class from the System.Speech.Synthesis[^] namespace.

Add a reference to the System.Speech assembly, and use:

Using Speech As New System.Speech.Synthesis.SpeechSynthesizer()
    Speech.SetOutputToDefaultAudioDevice()
    Speech.Speak("Welcome")
    Speech.Speak(TextBox1.Text)
End Using




NB: Your title suggests you want speech recognition, but the code block in your question suggests you want speech synthesis.

If you want to convert speech to text, rather than text to speech, you'll need to use the System.Speech.Recongition[^] namespace instead.

Voice Recognition - Speech Recognition with .NET Desktop Applications[^]


What you have tried is some SQL. It has nothing to do with the speech API. Take a look at vb.net sapi - Google Search[^]


这篇关于如何在VB.NET中创建用于将语音转换为文本的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆