将wav文件转换为文本格式(语音识别问题) [英] converting wav file to text format (Speech recognition problem)
本文介绍了将wav文件转换为文本格式(语音识别问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
在我的应用程序中,我正在将音频(wav文件)转换为文本格式.我只以Microsoft语音录制了wav文件.这是工作.但是语音识别无法正常工作.请帮助我纠正问题.我附上了我的代码.
提前谢谢.
Hi all,
In my application i am converting audio (wav file) to text format. I recorded the wav file in microsoft voice only. It is working. But the speech recognition does not work properly. Please help me to rectify the problem. I attached my code with it.
Thanks in advance.
Imports System
Imports System.Speech.Recognition
Public Class Form1
Dim WithEvents sre As SpeechRecognitionEngine
Private Sub btnLiterate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLiterate.Click
If TextBox1.Text.Trim.Length = 0 Then Exit Sub
sre.SetInputToWaveFile(TextBox1.Text)
Dim r As RecognitionResult
r = sre.Recognize()
If r Is Nothing Then
TextBox2.Text = "Could not fetch result"
Return
End If
TextBox2.Text = r.Text
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TextBox1.Text = String.Empty
Dim dr As DialogResult
dr = OpenFileDialog1.ShowDialog()
If dr = Windows.Forms.DialogResult.OK Then
If Not OpenFileDialog1.FileName.Contains("wav") Then
MessageBox.Show("Incorrect file")
Else
TextBox1.Text = OpenFileDialog1.FileName
End If
End If
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
sre = New SpeechRecognitionEngine()
End Sub
Private Sub sre_LoadGrammarCompleted(ByVal sender As Object, ByVal e As System.Speech.Recognition.LoadGrammarCompletedEventArgs) Handles sre.LoadGrammarCompleted
End Sub
Private Sub sre_SpeechHypothesized(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechHypothesizedEventArgs) Handles sre.SpeechHypothesized
System.Diagnostics.Debug.Print(e.Result.Text)
End Sub
Private Sub sre_SpeechRecognitionRejected(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechRecognitionRejectedEventArgs) Handles sre.SpeechRecognitionRejected
System.Diagnostics.Debug.Print("Rejected: " & e.Result.Text)
End Sub
Private Sub sre_SpeechRecognized(ByVal sender As Object, ByVal e As System.Speech.Recognition.SpeechRecognizedEventArgs) Handles sre.SpeechRecognized
System.Diagnostics.Debug.Print(e.Result.Text)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim words As String() = New String() {"triskaidekaphobia"}
Dim c As New Choices(words)
Dim grmb As New GrammarBuilder(c)
Dim grm As Grammar = New Grammar(grmb)
sre.LoadGrammar(grm)
End Sub
End Class
[edit]仅主题和标签-OriginalGriff [/edit]
[edit]Subject and Tags only - OriginalGriff[/edit]
推荐答案
基于您的变量名,这还不是一个认真的项目.您是否已从MS下载示例并运行它们?我将取样并逐步将其更改为您想要的,并在此之前进行每次更改的测试,因为您已经追逐了好几天.可能无法识别您的声音吗?您是否尝试了一种以上的输入语音?您是否尝试过不同陈述的录音?
Based on your variable names, this is not yet a serious project. Have you downloaded samples from MS and run them ? I''d take a sample and progressively change it to be what you want, and test with each change, at this point, as you''ve been chasing this for days. Is it possible it just can''t recognise your voice ? Have you tried more than one input voice ? Have you tried different recordings of different statements ?
这篇关于将wav文件转换为文本格式(语音识别问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文