我正在以 C 銳利視窗形式對文本應用程式進行演講。它作業正常并在視覺作業室中運行,但是
我正在使用此代碼來識別使用 Microsoft Azure 認知服務。一旦整個事情都被識別出來,我可以獲得 c 銳窗形式的置信度分數嗎?
我該如何解決這個問題?
我的代碼:
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.CognitiveServices.Speech;
using Microsoft.CognitiveServices.Speech.Audio;
using System.IO;
using System.Threading;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
private bool isRecognizing = false;
private SpeechRecognizer recognizer;
public Form1()
{
InitializeComponent();
}
private void initRecognizer()
{
SpeechConfig config = SpeechConfig.FromSubscription("key", "region");
if (Properties.Settings.Default.Punctuation)
{
config.SetServiceProperty("punctuation", "explicit", ServicePropertyChannel.UriQueryParameter);
}
//AudioConfig audioConfig = AudioConfig.FromMicrophoneInput();
recognizer = new SpeechRecognizer(config/*, audioConfig*/);
recognizer.Recognized = SpeechRecognizer_Recognized;
}
private void Form1_Load(object sender, EventArgs e)
{
initRecognizer();
}
private void SpeechRecognizer_Recognized(object sender, SpeechRecognitionEventArgs e)
{
if (e.Result.Reason == ResultReason.RecognizedSpeech)
{
if (e.Result.Text.ToLower().Equals("new line") || e.Result.Text.ToLower().Equals("newline"))
{
SendKeys.SendWait(Environment.NewLine);
}
else
{
SendKeys.SendWait(e.Result.Text);
}
}
}
private void Startstop()
{
if (isRecognizing)
{
recognizer.StopContinuousRecognitionAsync();
picture_btn.Image = Properties.Resources.green;
startToolStripMenuItem.Text = "Start";
pictureBox1.Enabled = true;
isRecognizing = false;
timer1.Stop();
timer1.Enabled = false;
}
else
{
picture_btn.Image = Properties.Resources.red;
startToolStripMenuItem.Text = "Stop";
pictureBox1.Enabled = false;
recognizer.StartContinuousRecognitionAsync();
isRecognizing = true;
timer1.Interval = 600;
timer1.Start();
timer1.Enabled = true;
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
Startstop();
}
private void Form1_Move(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Normal)
{
ShowInTaskbar = true;
notifyIcon1.Visible = true;
this.Hide();
notifyIcon1.ShowBalloonTip(1000);
}
}
private void Form1_MouseDoubleClick(object sender, MouseEventArgs e)
{
ShowInTaskbar = true;
notifyIcon1.Visible = false;
WindowState = FormWindowState.Normal;
this.WindowState = FormWindowState.Normal;
notifyIcon1.Visible = false;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
void SettingFormClosed(object sender, FormClosedEventArgs e)
{
initRecognizer();
}
private void startToolStripMenuItem_Click(object sender, EventArgs e)
{
Startstop();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (picture_btn.Tag.Equals("red"))
{
picture_btn.Image = Properties.Resources.grey;
picture_btn.Tag = "grey";
}
else
{
picture_btn.Image = Properties.Resources.red;
picture_btn.Tag = "red";
}
}
private void pictureBox1_Click_1(object sender, EventArgs e)
{
var myForm = new Form2();
myForm.FormClosed = SettingFormClosed;
myForm.Show();
}
private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Show();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason == CloseReason.UserClosing)
{
notifyIcon1.Visible = true;
this.Hide();
e.Cancel = true;
}
}
}
}
uj5u.com熱心網友回復:
在深入研究服務之前,您應該始終通讀服務檔案。該檔案將涵蓋重要的配置方面,并應詳細說明限制。
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/506810.html

