我集成了 Microsoft 认知服务 Speech to Text 的 30 天免费试用版。
var config = SpeechConfig.FromSubscription("fake", "westus");
using (var recognizer = new SpeechRecognizer(config))
{
lock (threadLocker)
{
waitingForReco = true;
}
var result = recognizer.RecognizeOnceAsync().Result;
string newMessage = string.Empty;
if (result.Reason == ResultReason.RecognizedSpeech)
{
newMessage = result.Text;
}
else if (result.Reason == ResultReason.NoMatch)
{
newMessage = "NOMATCH: Speech could not be recognized.";
}
else if (result.Reason == ResultReason.Canceled)
{
var cancellation = CancellationDetails.FromResult(result);
newMessage = $"CANCELED: Reason={cancellation.Reason} ErrorDetails={cancellation.ErrorDetails}";
}
lock (threadLocker)
{
message = newMessage;
waitingForReco = false;
}
}
当我使用免费演示 key 连接到 api 时,它可以工作。当我在 Azure 中创建 Azure 认知服务时,它总是返回“已取消”。
我必须为此演示 key 和生产 key 配置任何其他差异吗?
最佳答案
我认为您可能创建了错误的服务。对于认知服务来说,有很多种类型,比如face、luis、speechservice等等。在这种情况下,您需要在azure门户上创建资源时通过搜索语音来创建语音服务。
希望对你有帮助!
关于c# - 认知服务。 Azure 端点不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56045679/