是否可以以编程方式训练识别器提供 .wavs 而不是与麦克风交谈?
如果是这样,怎么做?,目前我有对0.wav文件中的音频执行识别并将识别的文本写入控制台的代码。
Imports System.IO
Imports System.Speech.Recognition
Imports System.Speech.AudioFormat
Namespace SampleRecognition
Class Program
Shared completed As Boolean
Public Shared Sub Main(ByVal args As String())
Using recognizer As New SpeechRecognitionEngine()
Dim dictation As Grammar = New DictationGrammar()
dictation.Name = "Dictation Grammar"
recognizer.LoadGrammar(dictation)
' Configure the input to the recognizer.
recognizer.SetInputToWaveFile("C:\Users\ME\v02\0.wav")
' Attach event handlers for the results of recognition.
AddHandler recognizer.SpeechRecognized, AddressOf recognizer_SpeechRecognized
AddHandler recognizer.RecognizeCompleted, AddressOf recognizer_RecognizeCompleted
' Perform recognition on the entire file.
Console.WriteLine("Starting asynchronous recognition...")
completed = False
recognizer.RecognizeAsync()
' Keep the console window open.
While Not completed
Console.ReadLine()
End While
Console.WriteLine("Done.")
End Using
Console.WriteLine()
Console.WriteLine("Press any key to exit...")
Console.ReadKey()
End Sub
' Handle the SpeechRecognized event.
Private Shared Sub recognizer_SpeechRecognized(ByVal sender As Object, ByVal e As SpeechRecognizedEventArgs)
If e.Result IsNot Nothing AndAlso e.Result.Text IsNot Nothing Then
Console.WriteLine(" Recognized text = {0}", e.Result.Text)
Else
Console.WriteLine(" Recognized text not available.")
End If
End Sub
' Handle the RecognizeCompleted event.
Private Shared Sub recognizer_RecognizeCompleted(ByVal sender As Object, ByVal e As RecognizeCompletedEventArgs)
If e.[Error] IsNot Nothing Then
Console.WriteLine(" Error encountered, {0}: {1}", e.[Error].[GetType]().Name, e.[Error].Message)
End If
If e.Cancelled Then
Console.WriteLine(" Operation cancelled.")
End If
If e.InputStreamEnded Then
Console.WriteLine(" End of stream encountered.")
End If
completed = True
End Sub
End Class
End Namespace
编辑
我了解使用培训向导对执行此操作很有用
通过打开语音识别,单击开始按钮->控制面板->轻松访问->语音识别来完成
.
如何使用自定义 wav 甚至 mp3 文件自定义训练语音识别?
使用培训向导(控制面板培训 UI)时,培训文件存储在 {AppData}\Local\Microsoft\Speech\Files\TrainingAudio中。
如何使用或进行自定义培训而不是使用培训向导?
语音控制面板在HKCU\Software\Microsoft\Speech\RecoProfiles\Tokens{ProfileGUID}{00000000-0000-0000-0000-0000000000000000}\Files键中为训练音频文件创建注册表项
由代码创建的注册表项是否必须放置在那里?
这样做的原因是我想用我自己的 wav 文件和单词和短语列表自定义训练,然后将所有内容转移到其他系统。