Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios IBM Watson语音到文本:无法使用Swift SDK转录文本_Ios_Iphone_Swift_Ibm Watson_Speech To Text - Fatal编程技术网

Ios IBM Watson语音到文本:无法使用Swift SDK转录文本

Ios IBM Watson语音到文本:无法使用Swift SDK转录文本,ios,iphone,swift,ibm-watson,speech-to-text,Ios,Iphone,Swift,Ibm Watson,Speech To Text,我正在使用IBM Watson speech to text iOS SDK转录实时音频。我通过可可豆安装了它。在将音频转录为文本时,我遇到了一个问题(身份验证) 安装的STT SDK版本为0.38.1 我已经配置了所有内容,正确创建了服务和凭证,并确保使用正确的apikey和URL实例化了SpeechToText。每当我调用startStreaming方法时,STT SDK都会打印一些错误日志,这似乎与身份验证挑战有关 下面是代码片段 let speechToText = SpeechToTe

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

安装的STT SDK版本为
0.38.1

我已经配置了所有内容,正确创建了服务和凭证,并确保使用正确的
apikey
URL
实例化了
SpeechToText
。每当我调用
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,对SpeechToTextV1进行了更改,下面的代码使用Speech-to-Text服务API密钥对我有效

除非该服务是在达拉斯以外的地区创建的,否则您不必大量传递URL。检查URL

你可以找到更多的例子


希望这有帮助

在过去的几天里,我在通过他们的web API登录时遇到了麻烦。我认为IBM方面正在进行一些工作。是的,您刚刚使用服务(在达拉斯地区创建)凭据进行了测试,这是正确的。它工作得很好#IBM于2018年12月6日发布了swift sdk的1.0.0版本。谢谢
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()
}