c# - 谷歌语音到文本使用相同的函数调用获得不准确的结果
问题描述
我希望在这里得到一些帮助。我构建了一个程序,该程序使用 Google Speech-to-Text 将带有语音数字的 wav 文件转换为文本。当我将这些上传到谷歌语音测试站点时,我得到了正确的结果,但是当我在自己的应用程序中使用相同的函数调用时,一些数字被吞掉了。例如,口语数字 1114343 在谷歌自己的网站上运行良好,但我的脚本会给我 14343 例如。这种不稳定的行为并不一致(顺便说一句,语音质量非常好),当我们不能依赖它时,它几乎破坏了我的程序。
我花了一些时间调试并使用五个替代结果,有时我会得到正确的结果,所以我选择了最长的。这也不起作用,因为它会使用书写数字“zwei”(二)的结果当然比“2”长。我也纠正了语音上下文,但结果完全没有区别。
有没有人遇到过这个问题并寻求帮助?从谷歌网站通过检查他们的函数 json 表示我正在使用完全相同的调用但结果不同。请注意,我在这两种情况下都使用德语。在此先感谢,这个错误让我发疯。
GoogleCredential googleCredential;
using (Stream m = new FileStream(keyPath, FileMode.Open))
googleCredential = GoogleCredential.FromStream(m);
var channel = new Grpc.Core.Channel(SpeechClient.DefaultEndpoint.Host,
googleCredential.ToChannelCredentials());
var speech = SpeechClient.Create(channel);
var ergebnis = "";
var response = speech.Recognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
EnableAutomaticPunctuation = false,
Model = "default",
LanguageCode = "de-DE",
MaxAlternatives = 5,
SpeechContexts = { new SpeechContext { Phrases = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0","11","12","13","14","15","16","17","18","19","20", "eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun", "null","zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn","zwanzig" } } }
}, RecognitionAudio.FromBytes(audioStream));
var wahrscheinlichstesErgebnis = "";
foreach(var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
Console.WriteLine(alternative.Transcript);
}
if (isnumberfield)
{
wahrscheinlichstesErgebnis = wahrscheinlichstesErgebnis + " " + result.Alternatives.OrderByDescending(x => Regex.Replace(x.Transcript, @"\D", "").Length).First().Transcript;
}
else
{
wahrscheinlichstesErgebnis = wahrscheinlichstesErgebnis + " " + result.Alternatives.OrderByDescending(x => x.Transcript.Length).First().Transcript;
}
}
解决方案
推荐阅读
- python-3.x - 最重要的是 JSON 解析和检查条件
- html - 已解决 Index.html 在服务器上找不到 Img
- apache-flink - Flink Operator 查看 UID
- reactjs - 调整 react-beautiful-dnd 的大小
- google-sheets - 使用查询拆分和重新加入名称
- reactjs - React 钩子是否使用两种方式绑定?如果是,那么与 React 相比,它是否会妨碍性能
- angular - 在 kendo-grid 中添加新条目时发生错误
- python - 图例颜色与 seaborn 不匹配
- ios - PickerView 键盘和点击以关闭 SwiftUI
- python - 熊猫矢量化循环并根据单元格值动态选择列标签