Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IBM Watson Speech To Text : Not able to transcribe the text using the Swift SDK

I am using IBM Watson speech to text iOS SDK for transcribing the real-time audio. I have installed it through cocoa pods. I am stuck with an issue (authentication) while transcribing the audio to text.

The installed STT SDK version is 0.38.1.

I have configured everything, created the service and credential correctly and also making sure SpeechToText instantiated with proper apikey and URL. Whenever I call the startStreaming method STT SDK prints some error log, which seems related to the authentication challenge.

Here is the code snippet.

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)

 }
}

Error Logs

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;
}

I have dug into IBM Watson SDK documentation even googled around this issue but did not find any relevant answer.

like image 212
Kamar Shad Avatar asked Nov 07 '22 23:11

Kamar Shad


1 Answers

A new version1.0.0 of Swift SDK is released with SpeechToTextV1 changes and the below code works for me with Speech to Text service API Key.

You don't have to extensively pass the URL until and unless the service is created in a region other than Dallas. Check the URLs 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()
}

You can find more examples here

Hope this helps!!

like image 137
Vidyasagar Machupalli Avatar answered Nov 14 '22 20:11

Vidyasagar Machupalli