Using Swift IoS SDK - https://github.com/watson-developer-cloud/ios-sdk Can't get the example to work and can't figure it out.
Get the following error message:
Optional(Error Domain=com.watsonplatform.texttospeech Code=400 "No JSON object could be decoded" UserInfo={NSLocalizedDescription=No JSON object could be decoded, NSLocalizedFailureReason=Bad Request})
Code is as follows: (removed credentials)
// // ViewController.swift // watsonspeaks // // Created by Vinod Ralh on 6/03/2016. // Copyright © 2016 Vinod Ralh. All rights reserved. //
import UIKit import WatsonDeveloperCloud
class ViewController: UIViewController { var player: AVAudioPlayer? override func viewDidLoad() {
super.viewDidLoad()
let tts = TextToSpeech(username: "xxxxxxxxx", password: "xxxxxxxxx")
tts.synthesize("All the problems of the world could be settled easily if men were only willing to think.") {
data, error in
if let audio = data {
do {
self.player = try AVAudioPlayer(data: audio)
self.player!.play()
} catch {
print("Couldn't create player.")
}
} else {
print(error)
}
}
}
}
Answer by Glenn R. Fisher (196) | Mar 10, 2016 at 03:14 PM
Hi Vinod. Thanks for posting this error! We're tracking it as a Github issue and pull request. We expect to merge/publish a fix shortly. Please check there for the latest information. Thanks!
Answer by Glenn R. Fisher (196) | Mar 19, 2016 at 03:55 AM
The pull request mentioned above fixed this issue in version 0.1.2 of the iOS SDK. To update to the most recent version of the iOS SDK, navigate to your project directory in the terminal and execute carthage update --platform iOS
.
Hope that helps! Thanks.
Watson Swift Ios SDK Text to Speech console msg - No JSON object could be decoded 3 Answers
How to display charts to users using Conversation service 0 Answers
Using the the Text to speech Service in an iOS Cordova App 3 Answers
DB2 iOS (Swift 4) Integration 1 Answer
Watson Assistant and Swift 1 Answer