The /whisk.system/watson-textToSpeech
package offers a convenient way to call Watson APIs to convert the text into speech.
The package includes the following actions.
Entity | Type | Parameters | Description |
---|---|---|---|
/whisk.system/watson-textToSpeech | package | username, password | Package to convert text into speech |
/whisk.system/watson-textToSpeech/textToSpeech | action | payload, voice, accept, encoding, username, password | Convert text into audio |
Note: The package /whisk.system/watson
is deprecated including the action /whisk.system/watson/textToSpeech
.
If you're using OpenWhisk from Bluemix, OpenWhisk automatically creates package bindings for your Bluemix Watson service instances.
Be sure to remember the name of the service instance and the Bluemix organization and space you're in.
wsk package refresh
created bindings: Bluemix_Watson_TextToSpeech_Credentials-1
wsk package list
packages /myBluemixOrg_myBluemixSpace/Bluemix_Watson_TextToSpeec_Credentials-1 private
If you're not using OpenWhisk in Bluemix or if you want to set up your Watson Text to Speech outside of Bluemix, you must manually create a package binding for your Watson Text to Speech service. You need the Watson Text to Speech service user name, and password.
Create a package binding that is configured for your Watson Speech to Text service.
wsk package bind /whisk.system/watson-textToSpeech myWatsonTextToSpeech -p username MYUSERNAME -p password MYPASSWORD
The /whisk.system/watson-textToSpeech/textToSpeech
action converts some text into an audio speech. The parameters are as follows:
username
: The Watson API user name.
password
: The Watson API password.
payload
: The text to convert into speech.
voice
: The voice of the speaker.
accept
: The format of the speech file.
encoding
: The encoding of the speech binary data.
Invoke the textToSpeech
action in your package binding to convert the text.
wsk action invoke myWatsonTextToSpeech/textToSpeech --blocking --result --param payload 'Hey.' --param voice 'en-US_MichaelVoice' --param accept 'audio/wav' --param encoding 'base64'
{ "payload": "<base64 encoding of a .wav file>" }