- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是使用 Microsoft.Speech 识别器(使用 Microsoft Speech Platform SDK 版本 11)的新手,我试图让它从一个简单的语法输出 n 最佳识别匹配,以及每个的置信度分数。
根据文档(如提到的 in the answer to this question ),应该可以使用 e.Result.Alternates
访问除得分最高的单词以外的已识别单词。然而,即使将置信度拒绝阈值重置为 0(这应该意味着什么都不会被拒绝),我仍然只得到一个结果,并且没有替代结果(尽管 SpeechHypothesized
事件表明至少其他单词中的一个似乎是在某些时候以非零置信度识别)。
我的问题:任何人都可以向我解释为什么我只得到一个识别词,即使置信度拒绝阈值设置为零?如何获得其他可能的匹配项及其置信度分数?我在这里想念什么?
下面是我的代码。提前感谢任何可以提供帮助的人:)
在下面的示例中,识别器被发送一个单词“news”的 wav 文件,并且必须从相似的单词(“noose”、“newts”)中进行选择。我想提取每个单词的识别器置信度得分列表(它们都应该不为零),即使它只会返回最好的一个(“新闻”)作为结果。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Speech.Recognition;
namespace SimpleRecognizer
{
class Program
{
static readonly string[] settings = new string[] {
"CFGConfidenceRejectionThreshold",
"HighConfidenceThreshold",
"NormalConfidenceThreshold",
"LowConfidenceThreshold"};
static void Main(string[] args)
{
// Create a new SpeechRecognitionEngine instance.
SpeechRecognitionEngine sre = new SpeechRecognitionEngine(); //en-US SRE
// Configure the input to the recognizer.
sre.SetInputToWaveFile(@"C:\Users\Anjana\Documents\news.wav");
// Display Recognizer Settings (Confidence Thresholds)
ListSettings(sre);
// Set Confidence Threshold to Zero (nothing should be rejected)
sre.UpdateRecognizerSetting("CFGConfidenceRejectionThreshold", 0);
sre.UpdateRecognizerSetting("HighConfidenceThreshold", 0);
sre.UpdateRecognizerSetting("NormalConfidenceThreshold", 0);
sre.UpdateRecognizerSetting("LowConfidenceThreshold", 0);
// Display New Recognizer Settings
ListSettings(sre);
// Build a simple Grammar with three choices
Choices topics = new Choices();
topics.Add(new string[] { "news", "newts", "noose" });
GrammarBuilder gb = new GrammarBuilder();
gb.Append(topics);
Grammar g = new Grammar(gb);
g.Name = "g";
// Load the Grammar
sre.LoadGrammar(g);
// Register handlers for Grammar's SpeechRecognized Events
g.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(gram_SpeechRecognized);
// Register a handler for the recognizer's SpeechRecognized event.
sre.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
// Register Handler for SpeechHypothesized
sre.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(sre_SpeechHypothesized);
// Start recognition.
sre.Recognize();
Console.ReadKey(); //wait to close
}
static void gram_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
Console.WriteLine("\nNumber of Alternates from Grammar {1}: {0}", e.Result.Alternates.Count.ToString(), e.Result.Grammar.Name);
foreach (RecognizedPhrase phrase in e.Result.Alternates)
{
Console.WriteLine(phrase.Text + ", " + phrase.Confidence);
}
}
static void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
{
Console.WriteLine("\nSpeech recognized: " + e.Result.Text + ", " + e.Result.Confidence);
Console.WriteLine("Number of Alternates from Recognizer: {0}", e.Result.Alternates.Count.ToString());
foreach (RecognizedPhrase phrase in e.Result.Alternates)
{
Console.WriteLine(phrase.Text + ", " + phrase.Confidence);
}
}
static void sre_SpeechHypothesized(object sender, SpeechHypothesizedEventArgs e)
{
Console.WriteLine("Speech from grammar {0} hypothesized: {1}, {2}", e.Result.Grammar.Name, e.Result.Text, e.Result.Confidence);
}
private static void ListSettings(SpeechRecognitionEngine recognizer)
{
foreach (string setting in settings)
{
try
{
object value = recognizer.QueryRecognizerSetting(setting);
Console.WriteLine(" {0,-30} = {1}", setting, value);
}
catch
{
Console.WriteLine(" {0,-30} is not supported by this recognizer.",
setting);
}
}
Console.WriteLine();
}
}
}
Original recognizer settings:
CFGConfidenceRejectionThreshold = 20
HighConfidenceThreshold = 80
NormalConfidenceThreshold = 50
LowConfidenceThreshold = 20
Updated recognizer settings:
CFGConfidenceRejectionThreshold = 0
HighConfidenceThreshold = 0
NormalConfidenceThreshold = 0
LowConfidenceThreshold = 0
Speech from grammar g hypothesized: noose, 0.2214646
Speech from grammar g hypothesized: news, 0.640804
Number of Alternates from Grammar g: 1
news, 0.9208503
Speech recognized: news, 0.9208503
Number of Alternates from Recognizer: 1
news, 0.9208503
最佳答案
我相信这是 SAPI 允许您询问 SR 引擎并不真正支持的东西的另一个地方。
Microsoft.Speech.Recognition 和 System.Speech.Recognition 都使用底层 SAPI 接口(interface)来完成它们的工作;唯一的区别是使用的是哪个 SR 引擎。 (Microsoft.Speech.Recognition 使用服务器引擎;System.Speech.Recognition 使用桌面引擎。)
替代主要是为听写设计的,而不是上下文无关的语法。您始终可以为 CFG 获得一个替代项,但替代生成代码看起来不会扩展 CFG 的替代项。
不幸的是,Microsoft.Speech.Recognition 引擎不支持听写。 (但是,它确实可以处理质量低得多的音频,并且不需要培训。)
关于.net - 微软语音识别 : Alternate results with confidence score?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18965286/
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
我正在使用 gradle 1.4,并将 build.gradle 重命名为 buildExpr.gradle,将 settings.gradle 重命名为 settingExpr.gradle,这两个
使用 Ubuntu 16.04.7 我试图将 python3.8 作为我的默认 python 版本。我按照 here 给出的说明进行操作,但最终标准 python 版本没有改变。每当我运行 pytho
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 6年前关闭。 Improve this questi
我有一个函数,它对其参数进行模式匹配,以在 StateT () Maybe () 中生成计算。这个计算在运行时可能会失败,在这种情况下,我希望当前的模式匹配分支失败,可以这么说。 我非常怀疑是否可能有
我知道这类问题已经回答过几次,但我给出了问题的上下文以期待一些其他的架构替代方案。 考虑一个 CExpression 类: class CExpression { public:
当我的红色、绿色或蓝色变量发生变化时,我正在尝试使用 Combine 来更新颜色。我看过的示例使用 sink() ,这似乎适合我,但 eraseToAnySubscriber 是 MIA,我找不到替代
最近我不得不搜索一些字符串值来查看哪个匹配某个模式。在用户输入搜索词之前,字符串值的数量和模式本身都不清楚。问题是我注意到每次我的应用程序运行以下行时: if (stringValue.mat
我希望制作包含类对象列表的类对象的深拷贝,每个类对象都有自己的一组内容。对象不包含比整数和列表更令人兴奋的东西(没有字典,没有等待生成的生成器等)。我在一个循环中对 500-800 个对象执行深度复制
我正在尝试在表格中插入一个简单的行。有人可以指出这里发生了什么吗? CREATE TABLE recommendation_engine_poc.user_by_category (
使用 Get-ChildItem | Get-Member 我可以看到对象的方法和属性。但是我如何看到例如的不同可能值属性?我可以用 Get-ChildItem | Where-Object {$_.
我有一个任务是编写简单的解析器生成器,所以我编写了类似 ANTLR 的语法并尝试解析像“foo:bar;”这样的简单文件,但得到了以下输出: [@0,0:2='foo',,1:0] [@1,3:3='
这个问题已经有答案了: Why order matters in this RegEx with alternation? (3 个回答) Order of regular expression op
Ax 2009 中的 MorphX 报表设计器似乎不是“最好的”报表设计器。我不知道是不是我的错,或者 morphx 报表设计器是否有太多错误而无法完成他的工作。我猜是否有一些替代方案可以为 Ax 2
除了 OWASP XSS 过滤软件之外,还有其他方法可以防止 XSS 攻击吗?如果可以在 apache 级别进行阻止,我需要建议。我不是安全专家,因此需要详细信息。感谢您的帮助 最佳答案 当数据向最终
在我的 Java EE 7 程序中,我想使用 @Alternative 根据上下文、生产或测试来注入(inject)不同的实现。我所做的就是在 beans.xml 文件中声明用 @Alternativ
我有一个文本文件,其中包含遵循替代模式的行,例如: name: SomeName counterA: 0, counterB: 0, counterC: 0 name: SomeNameB count
我知道标准的单例模式是这样的: 原创 public class Singleton1 { public static Singleton1 _Instance; public stat
在 Haskell 中,您可以像这样为临时变量创建 where 条件: f x | cond1 x = a | cond2 x = g a | otherwise = f (h x
我认为我能找到的所有适用于 Android 的自定义按钮教程都假设您使用三种图像作为按钮:普通图像、按下图像和聚焦图像。 不是本质上将给定按钮资源的大小增加三倍(并为美工/UX 人员创造更多工作),是
我是一名优秀的程序员,十分优秀!