4 Replies - 6497 Views - Last Post: 04 March 2010 - 03:07 AM Rate Topic: -----

#1 six_sic6  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 20-August 09

Voice detection for Speech to Text in C#

Posted 03 March 2010 - 03:41 PM

I am developing an application like speech to text in C#

My code is
namespace Recorder
{
    public partial class Form1 : Form
    {
        RecordUtil util;
        bool paused = false;
        public Form1()
        {
            InitializeComponent();
            util = new RecordUtil();
            btnPause.Enabled = false;
            btnStop.Enabled = false;
            txtOutput.Enabled = false;
        }

        private void btnRecord_Click(object sender, EventArgs e)
        {
            util.Initialize();
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                txtOutput.Text = saveFileDialog1.FileName;
               
                util.Encode(saveFileDialog1.FileName);
                util.StartRecording();
              
                btnPause.Enabled = true;
                btnStop.Enabled = true;
                btnRecord.Enabled = false;
            }
        }

        private void btnPause_Click(object sender, EventArgs e)
        {
            if (paused) 
            {
                util.Resume();
                btnPause.Text = "Pause";
            }
            else 
            {
                util.Pause();
                btnPause.Text = "Resume";
            }

            paused = !paused;
        }

        private void btnStop_Click(object sender, EventArgs e)
        {
            util.Stop();
            btnPause.Enabled = false;
            btnStop.Enabled = false;
            btnRecord.Enabled = true;
           
        }
    }
}

</code>

and the utility class is

<code>
namespace Recorder
{
   
    public class RecordUtil
    {
        //Form1 f;
        public int stream;
        private EncoderLAME encoder;
        private Un4seen.Bass.AddOn.Enc.ENCODEPROC proc;
        private RECORDPROC myRecordProc;

        public RecordUtil()
        {
            Bass.BASS_RecordInit(0);
        }

        public void Initialize()
        {
            myRecordProc = new RECORDPROC(MyRecording);
            stream = Bass.BASS_RecordStart(44100, 1, BASSRecord.BASS_RECORD_PAUSE, myRecordProc, 0);
        }

        public bool MyRecording(int handle, IntPtr buffer, int length, int user) { return true; }

        public void Encode(string output)
        {
            encoder = new EncoderLAME(stream);
            encoder.InputFile = null;
            encoder.OutputFile = output;
            encoder.LAME_Bitrate = (int)EncoderLAME.BITRATE.kbps_192;
            encoder.LAME_Mode = EncoderLAME.LAMEMode.Default;
            encoder.LAME_TargetSampleRate = (int)EncoderLAME.SAMPLERATE.Hz_44100;
            encoder.LAME_Quality = EncoderLAME.LAMEQuality.Quality;
        }

        public void StartRecording()
        {
           // f = new Form1();
           
            encoder.Start(null, 0);
            //Console.Write(stream);
            Bass.BASS_ChannelPlay(stream, true);
           
            // Console.Write(stream.ToString());
        }

        public void Pause()
        {
            encoder.Pause(true);
            Bass.BASS_ChannelPause(stream);
        }

        public void Resume()
        {
            encoder.Pause(false);
            Bass.BASS_ChannelPlay(stream, false);
        }

        public void Stop()
        {
            encoder.Stop();
            Bass.BASS_ChannelStop(stream);
        }

        ~RecordUtil()
        {
            encoder.Dispose();
            Bass.BASS_Free();
        }
    }
}



can anyone tell me how can i get the data of each speech while recording and show the each captured data from microphone to the textBox1??

This post has been edited by macosxnerd101: 29 December 2010 - 07:32 AM
Reason for edit:: Fixed code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Voice detection for Speech to Text in C#

#2 Ferencn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 71
  • View blog
  • Posts: 322
  • Joined: 01-February 10

Re: Voice detection for Speech to Text in C#

Posted 03 March 2010 - 03:52 PM

please change the <> around <code> and </code> into []...
Was This Post Helpful? 0
  • +
  • -

#3 six_sic6  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 20-August 09

Re: Voice detection for Speech to Text in C#

Posted 04 March 2010 - 01:19 AM

I am developing an application like speech to text in C#

My code is
namespace Recorder
{
public partial class Form1 : Form
{
RecordUtil util;
bool paused = false;
public Form1()
{
InitializeComponent();
util = new RecordUtil();
btnPause.Enabled = false;
btnStop.Enabled = false;
txtOutput.Enabled = false;
}

private void btnRecord_Click(object sender, EventArgs e)
{
util.Initialize();
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
txtOutput.Text = saveFileDialog1.FileName;

util.Encode(saveFileDialog1.FileName);
util.StartRecording();

btnPause.Enabled = true;
btnStop.Enabled = true;
btnRecord.Enabled = false;
}
}

private void btnPause_Click(object sender, EventArgs e)
{
if (paused) 
{
util.Resume();
btnPause.Text = "Pause";
}
else 
{
util.Pause();
btnPause.Text = "Resume";
}

paused = !paused;
}

private void btnStop_Click(object sender, EventArgs e)
{
util.Stop();
btnPause.Enabled = false;
btnStop.Enabled = false;
btnRecord.Enabled = true;

}
}
}




and the utility class is

namespace Recorder
{

public class RecordUtil
{
//Form1 f;
public int stream;
private EncoderLAME encoder;
private Un4seen.Bass.AddOn.Enc.ENCODEPROC proc;
private RECORDPROC myRecordProc;

public RecordUtil()
{
Bass.BASS_RecordInit(0);
}

public void Initialize()
{
myRecordProc = new RECORDPROC(MyRecording);
stream = Bass.BASS_RecordStart(44100, 1, BASSRecord.BASS_RECORD_PAUSE, myRecordProc, 0);
}

public bool MyRecording(int handle, IntPtr buffer, int length, int user) { return true; }

public void Encode(string output)
{
encoder = new EncoderLAME(stream);
encoder.InputFile = null;
encoder.OutputFile = output;
encoder.LAME_Bitrate = (int)EncoderLAME.BITRATE.kbps_192;
encoder.LAME_Mode = EncoderLAME.LAMEMode.Default;
encoder.LAME_TargetSampleRate = (int)EncoderLAME.SAMPLERATE.Hz_44100;
encoder.LAME_Quality = EncoderLAME.LAMEQuality.Quality;
}

public void StartRecording()
{
// f = new Form1();

encoder.Start(null, 0);
//Console.Write(stream);
Bass.BASS_ChannelPlay(stream, true);

// Console.Write(stream.ToString());
}

public void Pause()
{
encoder.Pause(true);
Bass.BASS_ChannelPause(stream);
}

public void Resume()
{
encoder.Pause(false);
Bass.BASS_ChannelPlay(stream, false);
}

public void Stop()
{
encoder.Stop();
Bass.BASS_ChannelStop(stream);
}

~RecordUtil()
{
encoder.Dispose();
Bass.BASS_Free();
}
}
}



can anyone tell me how can i get the data of each speech while recording and show the each captured data from microphone to the textBox1??
Was This Post Helpful? 0
  • +
  • -

#4 Ferencn  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 71
  • View blog
  • Posts: 322
  • Joined: 01-February 10

Re: Voice detection for Speech to Text in C#

Posted 04 March 2010 - 01:24 AM

What data do you want to show? The samplevalues? The length of the sample?
Was This Post Helpful? 0
  • +
  • -

#5 six_sic6  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 20-August 09

Re: Voice detection for Speech to Text in C#

Posted 04 March 2010 - 03:07 AM

I want to show the samplevalues in a textbox....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1