Click here to Skip to main content
15,920,801 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
actually i have code which is converted small files to text but here String Builder convert the complete file in to string and then display text while i want to extract audio in the blocks which display one than another respectively, in this way pause will reduce.kindly help me to resolve this issue...
C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Speech;
using System.Speech.Recognition;

namespace spechToText
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
           // open.Filter = "AUDIO file|* .wav |file audio|* .wma";
            if(open.ShowDialog() == DialogResult.OK)
            {
              SpeechRecognitionEngine sre = new SpeechRecognitionEngine();
                Grammar gr = new DictationGrammar();
                sre.LoadGrammar(gr);
                sre.SetInputToWaveFile(open.FileName);
                sre.BabbleTimeout = new TimeSpan(Int32.MaxValue);
                sre.InitialSilenceTimeout = new TimeSpan(Int32.MaxValue);
                sre.EndSilenceTimeout = new TimeSpan(100000000);
                sre.EndSilenceTimeoutAmbiguous = new TimeSpan(100000000);

                StringBuilder sb = new StringBuilder();
                while (true)
                {
                    try
                    {
                        var recText = sre.Recognize();
                        if (recText == null)
                        {
                            break;
                        }

                        sb.Append(recText.Text);
                    }
                    catch (Exception ex)
                    {
                        //handle exception      
                        //...

                        break;
                    }
                }
                richTextBox1.AppendText( sb.ToString());

               
            
            
            
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void richTextBox1_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
Posted
Updated 2-Feb-14 5:48am
v2

1 solution

What you need is the concordance of text and audio position. For each recognized block of text ("utterance"), there is also a start position and an end position. Look at the documentation for the Speech Recognition engine you use.
Then, of course, do not merely save the text, but an ordered List/Array of the concordance objects.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900