4

我正在寻找将通过 android 手机以 16000 录制的 .wav 文件转换为使用 C# 的文本;即 System.Speech 命名空间。我的代码在下面提到;

recognizer.SetInputToWaveFile(Server.MapPath("~/spoken.wav"));
recognizer.LoadGrammar(new DictationGrammar());
RecognitionResult result = recognizer.Recognize();
label1.Text = result.Text;

与示例 .wav “Hello world” 文件完美配合。但是,当我在手机上录制内容并尝试在电脑上转换时,转换后的文本与我录制的内容相差甚远。有什么方法可以确保音频文件被准确转录吗?

4

3 回答 3

3

手机的音频文件是用什么格式录制的?文件是否编码?Microsoft 识别器支持 PCM、ALaw 和 ULaw。确保以受支持的格式录制。您可以查看 RecognizerInfo.SupportedAudioFormats 属性 - http://msdn.microsoft.com/en-us/library/system.speech.recognition.recognizerinfo.supportedaudioformats(v=VS.90).aspx并检查识别器的格式版本支持。

你听过你在手机上录制的文件吗?吵吗?听起来清楚吗?确保您为识别器提供了最好的声音。

由于您使用的是听写语法,我假设您使用的是 Windows 7。您是否尝试过训练识别器?我的理解是听写语法性能可以通过训练来提高,标准的 Windows 7 语音识别训练将有助于其性能 - http://windows.microsoft.com/en-US/windows7/Set-up-Speech-Recognition

StackOverflow 上的其他一些问题也可能会给您一些见解。请参阅好的语音识别 API开始。

于 2011-05-10T13:15:33.687 回答
-1

可以在此处找到您想要的完整实施细节:

使用 System.Speech 将 WAV 音频转换为文本

于 2012-03-23T20:26:09.890 回答
-2
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 

或试试这个链接 音频到文本软件免费

于 2012-01-03T12:19:38.297 回答