Google云API语法
Google Cloud API grammar
使用我在 youtube 视频上找到的代码(不知道我是否能够 post):
if (File.Exists("audio.raw"))
{
var speech = SpeechClient.Create();
var response = speech.Recognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 16000,
LanguageCode = "iw",
}, RecognitionAudio.FromFile("audio.raw"));
textBox1.Text = "";
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
textBox1.Text = textBox1.Text + " " + alternative.Transcript;
}
}
if(textBox1.Text.Length == 0)
textBox1.Text = "No Data ";
StreamingMicRecognizeAsync(10);
}
else
{
textBox1.Text = "Audio File Missing ";
}
我能够创建基于 google 云 api 的语音识别。
但是,我找不到以这种方式创建语法的方法,因此我正在寻找建议。
如何为 google api 创建语法过滤?
是否有人做了一个项目,或者一些 api 已经在做这个项目(例如:输入 "one"、"two"、[=35 的主字符串=] 然后如果你输入例如 "tu" 它会输出 "two",如果你输入 "today" 它会输出不合适的东西等等,就像微软的语法)
我读过有关 SpeechContexts 的内容,但它只能在 c# 中读取,我真的无法使用它。
有什么建议吗?
编辑:
还有我如何离线使用它?会很棒...或者至少让它更快。
我尝试了流媒体选项,但它根本不准确。
假设您只想将 SpeechContext
添加到您的请求中,只需将实例添加到 RecognitionConfig
的 SpeechContexts
属性:
var context = new SpeechContext { Phrases = { "first", "second" } };
var config = new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 16000,
LanguageCode = "iw",
SpeechContexts = { context }
};
(一般来说,protobuf 中表示映射和列表的 properties 是只读的,但您可以向它们添加 - 显式调用 Add
,或使用集合初始值设定项如上。)
使用我在 youtube 视频上找到的代码(不知道我是否能够 post):
if (File.Exists("audio.raw"))
{
var speech = SpeechClient.Create();
var response = speech.Recognize(new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 16000,
LanguageCode = "iw",
}, RecognitionAudio.FromFile("audio.raw"));
textBox1.Text = "";
foreach (var result in response.Results)
{
foreach (var alternative in result.Alternatives)
{
textBox1.Text = textBox1.Text + " " + alternative.Transcript;
}
}
if(textBox1.Text.Length == 0)
textBox1.Text = "No Data ";
StreamingMicRecognizeAsync(10);
}
else
{
textBox1.Text = "Audio File Missing ";
}
我能够创建基于 google 云 api 的语音识别。
但是,我找不到以这种方式创建语法的方法,因此我正在寻找建议。
如何为 google api 创建语法过滤?
是否有人做了一个项目,或者一些 api 已经在做这个项目(例如:输入 "one"、"two"、[=35 的主字符串=] 然后如果你输入例如 "tu" 它会输出 "two",如果你输入 "today" 它会输出不合适的东西等等,就像微软的语法)
我读过有关 SpeechContexts 的内容,但它只能在 c# 中读取,我真的无法使用它。
有什么建议吗?
编辑:
还有我如何离线使用它?会很棒...或者至少让它更快。
我尝试了流媒体选项,但它根本不准确。
假设您只想将 SpeechContext
添加到您的请求中,只需将实例添加到 RecognitionConfig
的 SpeechContexts
属性:
var context = new SpeechContext { Phrases = { "first", "second" } };
var config = new RecognitionConfig()
{
Encoding = RecognitionConfig.Types.AudioEncoding.Linear16,
SampleRateHertz = 16000,
LanguageCode = "iw",
SpeechContexts = { context }
};
(一般来说,protobuf 中表示映射和列表的 properties 是只读的,但您可以向它们添加 - 显式调用 Add
,或使用集合初始值设定项如上。)