是否有可能以編程方式訓練識別器給出.wavs而不是與麥克風對話?如何以編程方式訓練SpeechRecognitionEngine並將音頻文件轉換爲c#或vb.net中的文本
如果是這樣,怎麼做呢?,目前我的代碼在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的} \本地\微軟\語音\文件\ TrainingAudio。
如何使用或進行自定義培訓而不是使用培訓嚮導?
的語音控制面板中的關鍵HKCU \軟件\微軟\語音\ RecoProfiles \ {令牌} ProfileGUID培訓音頻文件{00000000-0000-0000-0000-0000000000000000} \文件創建註冊表項
由代碼創建的註冊表項必須放在那裏嗎?
這樣做的原因是我想用我自己的wav文件和單詞和短語列表自定義訓練,然後將所有文件轉移到其他系統。