gpt4 book ai didi

ios - IBM Watson 语音转文本 : Not able to transcribe the text using the Swift SDK

转载 作者:搜寻专家 更新时间:2023-10-31 19:35:49 26 4
gpt4 key购买 nike

我正在使用 IBM Watson speech to text iOS SDK 来转录实时音频。我已经通过 cocoa pod 安装了它。我在将音频转录为文本时遇到问题(身份验证)。

安装的STT SDK版本为0.38.1

我已配置好所有内容,正确创建了服务和凭证,并确保 SpeechToText 使用正确的 apikeyURL 实例化。每当我调用 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 文档,甚至用谷歌搜索了这个问题,但没有找到任何相关答案。

最佳答案

新版本1.0.0 Swift SDK 随 SpeechToTextV1 更改一起发布,下面的代码适用于我使用 Speech to Text 服务 API key 。

除非服务是在达拉斯以外的区域创建的,否则您不必广泛传递 URL。检查 URL here

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()
}

您可以找到更多示例 here

希望这对您有所帮助!

关于ios - IBM Watson 语音转文本 : Not able to transcribe the text using the Swift SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53609766/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com