خرید بک لینک

Vote count: 0

I've been building an AI Speech Recognition program by looking at a tutorial from youtube and it runs proper;y without any errors. But it doesn't recognize my voice input. I'm using System.speech library. This is the code that I used

enter code here

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.Synthesis;
using System.Speech.Recognition;

namespace VoiceBot
{
    public partial class Form1 : Form
    {
        SpeechSynthesizer s = new SpeechSynthesizer {};
        Choices list = new Choices {};


        public Form1()
        {

            SpeechRecognitionEngine rec = new SpeechRecognitionEngine { };

            list.Add(new string[] { "Hello", "How are you?", "What time is it?" });
            Grammar gr = new Grammar(new GrammarBuilder(list));

            try
            {
                rec.RequestRecognizerUpdate();
                rec.LoadGrammar(gr);
                rec.SpeechRecognized += rec_SpeachRecognized;
                rec.SetInputToDefaultAudioDevice();
                rec.RecognizeAsync(RecognizeMode.Multiple);
            }
            catch { retu; }


            s.SelectVoiceByHints(VoiceGender.Female);
            s.Speak("Hello, My name is voice bot, How may I help you?");
            InitializeComponent();
        }

        public void say(String h)
        {
            s.Speak(h);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void rec_SpeachRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            String r = e.Result.Text;

            //what you say
            if(r== "hello")
            {
                //what it says
                say("Hi");
            }

            if (r == "how are you?")
            {
                say("Great, and you?");
            }
        }
    }
}

asked 33 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 2 تير 1395 ساعت: 8:20

صفحه بندی