To install the Watson Speech Plugin in your Cordova Project, run in terminal:
cordova plugin add https://github.com/CognitiveBuild/WatsonSpeechPlugin.git
- iOS: Update your username/password of the Speech-to-Text and Text-to-Speech services in Credential.plist
- Android: Update in Java code of the native Plugins
WatsonSDK.SpeechToText.recognize(function(data){
// data
if(data.iscompleted === WatsonSDK.Constants.YES) {
// connection closed, ready for another round of speech recognition
return;
}
if(data.isfinal === WatsonSDK.Constants.YES) {
// last transcript is returned, the WebSocket is automatically disconnected
}
// evaluate the transcription
console.log(data.message);
}, function(error){
// error
});
var text = 'Hello World!';
WatsonSDK.TextToSpeech.synthesize(function(data){
// success
}, function(error){
// error
}, [text]);
var text = 'Hello World!';
var customization_id = 'your-customization-id';
WatsonSDK.TextToSpeech.synthesize(function(data){
// success
}, function(error){
// error
}, [text, customization_id]);
To uninstall the Watson Speech Plugin from your Corodva Project, run in terminal:
cordova plugin remove WatsonSpeechPlugin
Copyright 2017 GCG GBS CTO Office under the Apache 2.0 license.