[英]IBM Watson Speech To Text : Not able to transcribe the text using the Swift SDK
我正在使用 IBM Watson 语音文本 iOS SDK 来转录实时音频。 我已经通过可可豆荚安装了它。 在将音频转录为文本时,我遇到了一个问题(身份验证)。
安装的 STT SDK 版本是0.38.1
。
我已经配置了所有内容,正确创建了服务和凭据,并确保SpeechToText
使用正确的apikey
和URL
实例化。 每当我调用startStreaming
方法时,STT SDK 都会打印一些错误日志,这似乎与身份验证挑战有关。
这是代码片段。
let speechToText = SpeechToText(apiKey: Credentials.SpeechToTextAPIKey,iamUrl: Credentials.SpeechToTextURL)
var accumulator = SpeechRecognitionResultsAccumulator()
func startStreaming() {
var settings = RecognitionSettings(contentType: "audio/ogg;codecs=opus")
settings.interimResults = true
let failure = { (error: Error) in print(error) }
speechToText.recognizeMicrophone(settings: settings, failure: failure) { results in
accumulator.add(results: results)
print(accumulator.bestTranscript)
}
}
错误日志
CredStore - performQuery - Error copying matching creds. Error=-25300,
query={
class = inet;
"m_Limit" = "m_LimitAll";
ptcl = htps;
"r_Attributes" = 1;
sdmn = "IBM Watson Gateway(Log-in)";
srvr = "gateway-syd.watsonplatform.net";
sync = syna;
}
我已经深入研究了 IBM Watson SDK 文档,甚至用谷歌搜索了这个问题,但没有找到任何相关的答案。
Swift SDK 的新版本1.0.0发布了 SpeechToTextV1 更改,下面的代码适用于我的 Speech to Text 服务 API 密钥。
除非服务是在达拉斯以外的地区创建的,否则您不必大量传递 URL。 检查 这里的 URL
import SpeechToTextV1 // If sdk is installed using Carthage.
import SpeechToText // If sdk is installed as a pod
let apiKey = "your-api-key"
let speechToText = SpeechToText(apiKey: apiKey)
var accumulator = SpeechRecognitionResultsAccumulator()
func startStreaming() {
var settings = RecognitionSettings(contentType: "audio/ogg;codecs=opus")
settings.interimResults = true
speechToText.recognizeMicrophone(settings: settings) { response, error in
if let error = error {
print(error)
}
guard let results = response?.result else {
print("Failed to recognize the audio")
return
}
accumulator.add(results: results)
print(accumulator.bestTranscript)
}
}
func stopStreaming() {
speechToText.stopRecognizeMicrophone()
}
您可以在此处找到更多示例
希望这可以帮助!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.