Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 117,621 C# Programmers for FREE! Ask your question and get quick answers from experts. There are 1,984 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



SR voice differntiation

 
Reply to this topicStart new topic

SR voice differntiation

hiphop_13
post 14 Jul, 2008 - 03:32 AM
Post #1


New D.I.C Head

*
Joined: 4 Jun, 2007
Posts: 36



Thanked 1 times
My Contributions


Hi all,

I have the following appliation that start dictation from a microphone, what i want but failed to do till now is changing the color of the text when another speaker speaks. i.e. each speaker words will be displayed in a different color, or before each speaker words Speaker A:

here's the code
CODE

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using SpeechLib;
using System.IO;
using System.Threading;


namespace WindowsApplication14
{
    public partial class Form1 : Form
    {
      
        private SpeechLib.SpSharedRecoContext objRecoContext;
        private SpeechLib.ISpeechRecoGrammar grammar;
        private string strData = "No recording yet";

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (objRecoContext == null)
                {
                    objRecoContext = new SpeechLib.SpSharedRecoContext();
                    objRecoContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(RecoContext_Recognition);
                  
                    
                    grammar = objRecoContext.CreateGrammar(1);
                    grammar.DictationLoad("", SpeechLoadOption.SLOStatic);
                }
                grammar.DictationSetState(SpeechRuleState.SGDSActive);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Exception caught when initializing SAPI." + " This application may not run correctly.\r\n\r\n" + ex.ToString(), "Error");
            }

        }


        private void button2_Click(object sender, EventArgs e)
        {
            grammar.DictationSetState(SpeechRuleState.SGDSInactive);

        }

        public void RecoContext_Recognition(int StreamNumber, object StreamPosition, SpeechRecognitionType RecognitionType, ISpeechRecoResult Result)
        {
            Result.SpeakAudio();
            strData = Result.PhraseInfo.GetText(0, -1, true);
            Debug.WriteLine("Recognition: " + strData + ", " + StreamNumber + ", " + StreamPosition);
            textBox1.Text += " " + strData;
            //strData = strData;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync;
                SpVoice Voice = new SpVoice();
                if (checkBox1.Checked)
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    sfd.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav";
                    sfd.Title = "Save to a wave file";
                    sfd.FilterIndex = 2;
                    sfd.RestoreDirectory = true;
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite;
                        SpFileStream SpFileStream = new SpFileStream();
                        SpFileStream.Open(sfd.FileName, SpFileMode, false);
                        Voice.AudioOutputStream = SpFileStream;
                        Voice.Speak("You recorded the following message " + strData, SpFlags);
                        Voice.WaitUntilDone(Timeout.Infinite);
                        SpFileStream.Close();
                    }
                }
                else
                {
                    Voice.Speak("You recorded the following message" + strData, SpFlags);
                }
            }
            catch
            {
                MessageBox.Show("Speak error", "SimpleTTS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            
            
                File.WriteAllText("C:\\Documents and Settings\\$..Hiba..$\\Desktop\\s.txt", textBox1.Text);

            
        }

        
    }
}


Thanks
User is offlineProfile CardPM

Go to the top of the page


jacobjordan
post 14 Jul, 2008 - 08:53 AM
Post #2


class Me : Perfection

Group Icon
Joined: 11 Jun, 2008
Posts: 830



Thanked 19 times

Dream Kudos: 1450
My Contributions


Just so you know, i have used speech dictation before in my applications, and instead of using the SpeechLib library, i prefer to use the .NET System.Speech library, since it is far easier to use. Back to the point, i don't really understand your question. If you are asking that you want Speech to detect if a different person is speaking than the person before, sorry, but Speech can't do that.
User is offlineProfile CardPM

Go to the top of the page

hiphop_13
post 14 Jul, 2008 - 11:53 AM
Post #3


New D.I.C Head

*
Joined: 4 Jun, 2007
Posts: 36



Thanked 1 times
My Contributions


Thanks for your reply.
Too bad i can't differentiate speakers, my aim was to develop an application that the deaf can use to know what every person speaks...
Is there any other way you recommend?

Thanks
User is offlineProfile CardPM

Go to the top of the page

jacobjordan
post 14 Jul, 2008 - 01:11 PM
Post #4


class Me : Perfection

Group Icon
Joined: 11 Jun, 2008
Posts: 830



Thanked 19 times

Dream Kudos: 1450
My Contributions


Speech recognition can't do what you want. Unless you want to program your own speech recognition engine, and make it smart enough to differentiate speakers (and get rich when you sell it), i don't know of a way. One thing you might want to consider is to have a command built in to change speakers. For example, if speaker 1 wanted to speak, he could say "Speaker One" first, and the system would know it was him speaking.
User is offlineProfile CardPM

Go to the top of the page

hiphop_13
post 14 Jul, 2008 - 04:16 PM
Post #5


New D.I.C Head

*
Joined: 4 Jun, 2007
Posts: 36



Thanked 1 times
My Contributions


Thank you, really nice idea.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/8/08 12:19AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month