"Cannot find the requested data item, such as a data key or value. " Hogy oldjam meg?
Microsoft.Speech (Speech SDK 11)
"
_rec.SetInputToDefaultAudioDevice(); // <---- "Cannot find the requested data item, such as a data key or value."
"
"
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 Microsoft.Speech.Recognition;
namespace AI
{
public partial class Form1 : Form
{
SpeechRecognitionEngine _rec = new SpeechRecognitionEngine();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Choices ch = new Choices();
ch.Add(new string[] { "Hello, Hi, Help" });
GrammarBuilder gb = new GrammarBuilder();
gb.Append(ch);
Grammar grammar = new Grammar(gb);
try
{
_rec.LoadGrammarAsync(grammar);
_rec.SetInputToDefaultAudioDevice(); // <---- "Cannot find the requested data item, such as a data key or value."
_rec.SpeechRecognized += _rec_SpeechRecognized;
}
catch (Exception ex)
{
richTextBox1.Text = (richTextBox1.Text + "\n" + ex.Message);
}
}
private void _rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
richTextBox1.Text = (richTextBox1.Text + "\n" + e.Result.Text);
}
private void Button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Kapcsolódó kérdések:
Minden jog fenntartva © 2025, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!