Laboratoriya ishi №1 Mavzu: C# asosida nutqni tanish algoritmlarini o’rganish Ishdan maqsad



Download 27,45 Kb.
bet2/2
Sana31.08.2021
Hajmi27,45 Kb.
#161201
1   2
Bog'liq
Lab 1

Amaliy qism: Endi esa nutqni tanishga oid C# da bitta misol ko’ramiz.

Nutqni tanishni initializatsiya qilamiz:

 

// Create a new SpeechRecognizer instance.



SpeechRecognizer sr = new SpeechRecognizer();

Nuqtni tanish grammatikasini yaratamiz:

Choices colors = new Choices();

colors.Add(new string[] {"red", "green", "blue"});

GrammarBuilder gb = new GrammarBuilder();

gb.Append(colors);

// Create the Grammar instance.

Grammar g = new Grammar(gb);

Nutqni tanishni ichiga grammatikadan yuklaymiz:

sr.LoadGrammar(g);

Nutqni tanishni natijasi hodisasi uchun registr:

sr.SpeechRecognized += new EventHandler(sr_SpeechRecognized);

Nutqni tanishni natijasi hodisasini yaratish:

void sr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)

{

MessageBox.Show(e.Result.Text);



}

Yuqoridagilar bo’yicha misol:

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Speech.Recognition;

namespace WindowsFormsApplication1

{

public partial class Form1 : Form



{

public Form1()

{

InitializeComponent();



}

private void Form1_Load(object sender, EventArgs e)

{

// Create a new SpeechRecognitionEngine instance.



SpeechRecognizer recognizer = new SpeechRecognizer();

// Create a simple grammar that recognizes "red", "green", or "blue".

Choices colors = new Choices();

colors.Add(new string[] { "red", "green", "blue" });

// Create a GrammarBuilder object and append the Choices object.

GrammarBuilder gb = new GrammarBuilder();

gb.Append(colors);

// Create the Grammar instance and load it into the speech recognition engine.

Grammar g = new Grammar(gb);

recognizer.LoadGrammar(g);

 

// Register a handler for the SpeechRecognized event.



recognizer.SpeechRecognized +=

new EventHandler(sre_SpeechRecognized);

}

// Create a simple handler for the SpeechRecognized event.



void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)

{

MessageBox.Show("Speech recognized: " + e.Result.Text);



}

Windows formasi ilovasi uchun autogeneratsiya uchun yoziladigan kodlar:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Windows.Forms;

namespace WindowsFormsApplication1

{

static class Program



{

// The main entry point for the application.

[STAThread]

static void Main()

{

Application.EnableVisualStyles();



Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());



}

}

}
Download 27,45 Kb.

Do'stlaringiz bilan baham:
1   2




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish