【问题标题】:IBM Watson Speech To Text : Not able to transcribe the text using the Swift SDKIBM Watson Speech To Text:无法使用 Swift SDK 转录文本
【发布时间】:2019-05-05 16:36:54
【问题描述】:

我正在使用 IBM Watson Speech to Text iOS SDK 来转录实时音频。我已经通过可可豆荚安装了它。在将音频转录为文本时,我遇到了一个问题(身份验证)。

安装的 STT SDK 版本为0.38.1

我已经配置了所有内容,正确创建了服务和凭据,并确保 SpeechToText 使用正确的 apikeyURL 实例化。每当我调用startStreaming 方法时,STT SDK 都会打印一些错误日志,这似乎与身份验证挑战有关。

这里是代码sn-p。

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 文档,甚至围绕这个问题进行了谷歌搜索,但没有找到任何相关答案。

【问题讨论】:

  • 过去几天我一直无法通过他们的 Web API 登录。我认为 IBM 那边发生了一些事情。

标签: ios iphone swift ibm-watson speech-to-text


【解决方案1】:

Swift SDK 的新版本1.0.0 随 SpeechToTextV1 更改发布,以下代码适用于我的 Speech to Text 服务 API 密钥。

除非服务是在达拉斯以外的地区创建的,否则您不必大量传递 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

希望这会有所帮助!

【讨论】:

  • 是的,您刚刚使用服务(在达拉斯地区创建)凭据进行了测试。它工作正常。 #IBM 于 2018 年 12 月 6 日发布 1.0.0 版 swift sdk。谢谢
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-07-28
  • 2018-01-01
  • 2021-12-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-04-02
相关资源
最近更新 更多