This is an automated email from the ASF dual-hosted git repository. dgrove pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-catalog.git
The following commit(s) were added to refs/heads/master by this push: new acdb5b9 remove IBM Watson packages; moved to an IBM repo (#298) acdb5b9 is described below commit acdb5b9db61ac72c85f0098f75bafc9632808179 Author: David Grove <dgrove-...@users.noreply.github.com> AuthorDate: Fri Jun 14 20:46:56 2019 -0400 remove IBM Watson packages; moved to an IBM repo (#298) --- README.md | 7 +- packages/installCatalog.sh | 3 - packages/installCatalogUsingWskdeploy.sh | 6 - packages/installWatson.sh | 154 --------------------- packages/watson-speechToText/README.md | 102 -------------- packages/watson-speechToText/manifest.yaml | 151 -------------------- packages/watson-speechToText/speechToText.js | 139 ------------------- packages/watson-textToSpeech/README.md | 91 ------------ packages/watson-textToSpeech/manifest.yaml | 101 -------------- packages/watson-textToSpeech/textToSpeech.js | 85 ------------ packages/weather/README.md | 2 +- tests/build.gradle | 1 - .../test/scala/packages/watson/WatsonTests.scala | 71 ---------- 13 files changed, 3 insertions(+), 910 deletions(-) diff --git a/README.md b/README.md index fd467dc..fd594f4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ This openwhisk-catalog maintains the package catalogs of openwhisk. In OpenWhisk, the catalog of packages gives you an easy way to enhance your app with useful capabilities, and to access external services in the ecosystem. Examples of external services that are OpenWhisk-enabled -include IBM Watson API, the Weather Company, Slack, and GitHub.system packages and sample packages. +include the Weather Company, Slack, and GitHub.system packages and sample packages. The catalog is available as packages in the `/whisk.system` namespace. See [Browsing packages](https://github.com/openwhisk/openwhisk/blob/master/docs/packages.md#browsing-packages) for information about how to browse the catalog by using the command line tool. @@ -54,10 +54,7 @@ in the format of IP or hostname. The third argument `cli_path` is the full path | Package | Description | | --- | --- | | [/whisk.system/github](./packages/github/README.md) | offers a convenient way to use the [GitHub APIs](https://developer.github.com/). | -| [/whisk.system/slack](./packages/watson-translator/README.md) | offers a convenient way to use the [Slack APIs](https://api.slack.com/). | -| [/whisk.system/watson-translator](./packages/watson-translator/README.md) | Package for text translation and language identification| -| [/whisk.system/watson-speechToText](./packages/watson-speechToText/README.md) | Package to convert speech into text| -| [/whisk.system/watson-textToSpeech](./packages/watson-textToSpeech/README.md) | Package to convert text into speech| +| [/whisk.system/slack](./packages/slack/README.md) | offers a convenient way to use the [Slack APIs](https://api.slack.com/). | | [/whisk.system/weather](./packages/weather/README.md) | Services from the Weather Company Data for IBM Bluemix API| | [/whisk.system/websocket](./packages/websocket/README.md) | Package to send messages to Web Socket server| diff --git a/packages/installCatalog.sh b/packages/installCatalog.sh index cc02cc6..ecb08ba 100755 --- a/packages/installCatalog.sh +++ b/packages/installCatalog.sh @@ -39,9 +39,6 @@ fi runPackageInstallScript "$SCRIPTDIR" installGit.sh runPackageInstallScript "$SCRIPTDIR" installSlack.sh runPackageInstallScript "$SCRIPTDIR" installSystem.sh -if [ $SKIP_DEPRECATED_PACKAGES == "false" ]; then - runPackageInstallScript "$SCRIPTDIR" installWatson.sh -fi runPackageInstallScript "$SCRIPTDIR" installWeather.sh runPackageInstallScript "$SCRIPTDIR" installWebSocket.sh diff --git a/packages/installCatalogUsingWskdeploy.sh b/packages/installCatalogUsingWskdeploy.sh index 830873d..4c7dc9b 100755 --- a/packages/installCatalogUsingWskdeploy.sh +++ b/packages/installCatalogUsingWskdeploy.sh @@ -42,12 +42,6 @@ deployProject "$SCRIPTDIR/slack/" deployProject "$SCRIPTDIR/utils/" -if [ $SKIP_DEPRECATED_PACKAGES == "false" ]; then - deployProject "$SCRIPTDIR/watson-speechToText/" -fi - -deployProject "$SCRIPTDIR/watson-textToSpeech/" - deployProject "$SCRIPTDIR/weather/" deployProject "$SCRIPTDIR/websocket/" diff --git a/packages/installWatson.sh b/packages/installWatson.sh deleted file mode 100755 index ca0813d..0000000 --- a/packages/installWatson.sh +++ /dev/null @@ -1,154 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# use the command line interface to install Watson package. -# -SCRIPTDIR="$(cd $(dirname "$0")/ && pwd)" -PACKAGE_HOME=$SCRIPTDIR -source "$PACKAGE_HOME/util.sh" - -echo Installing Watson package. - - -createPackage watson-speechToText \ - -a description "Actions for the Watson analytics APIs to convert speech into text" \ - -a parameters '[ {"name":"bluemixServiceName", "required":false, "bindTime":true}, {"name":"username", "required":false}, {"name":"password", "required":false, "type":"password"} ]' \ - -a tags '["watson"]' \ - -p bluemixServiceName 'speech_to_text' - -createPackage watson-textToSpeech \ - -a description "Actions for the Watson analytics APIs to convert text into speech" \ - -a parameters '[ {"name":"bluemixServiceName", "required":false, "bindTime":true}, {"name":"username", "required":false}, {"name":"password", "required":false, "type":"password"} ]' \ - -a tags '["watson"]' \ - -p bluemixServiceName 'text_to_speech' - -waitForAll - -install "$PACKAGE_HOME/watson-speechToText/speechToText.js" \ - watson-speechToText/speechToText \ - -a description 'Convert speech to text' \ - -a parameters '[ - { - "name": "content_type", - "required": true, - "description": "The MIME type of the audio" - }, - { - "name": "model", - "required": false, - "description": "The identifier of the model to be used for the recognition request" - }, - { - "name": "continuous", - "required": false, - "description": "Indicates whether multiple final results that represent consecutive phrases separated by long pauses are returned" - }, - { - "name": "inactivity_timeout", - "required": false, - "description": "The time in seconds after which, if only silence (no speech) is detected in submitted audio, the connection is closed" - }, - { - "name": "interim_results", - "required": false, - "description": "Indicates whether the service is to return interim results" - }, - { - "name": "keywords", - "required": false, - "description": "A list of keywords to spot in the audio" - }, - { - "name": "keywords_threshold", - "required": false, - "description": "A confidence value that is the lower bound for spotting a keyword" - }, - { - "name": "max_alternatives", - "required": false, - "description": "The maximum number of alternative transcripts to be returned" - }, - { - "name": "word_alternatives_threshold", - "required": false, - "description": "A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative" - }, - { - "name": "word_confidence", - "required": false, - "description": "Indicates whether a confidence measure in the range of 0 to 1 is to be returned for each word" - }, - { - "name": "timestamps", - "required": false, - "description": "Indicates whether time alignment is returned for each word" - }, - { - "name": "X-Watson-Learning-Opt-Out", - "required": false, - "description": "Indicates whether to opt out of data collection for the call" - }, - { - "name": "watson-token", - "required": false, - "description": "Provides an authentication token for the service as an alternative to providing service credentials" - }, - { - "name": "encoding", - "required": true, - "description": "The encoding of the speech binary data" - }, - { - "name": "payload", - "required": true, - "description": "The encoding of the speech binary data" - }, - { - "name": "username", - "required": true, - "bindTime": true, - "description": "The Watson service username" - }, - { - "name": "password", - "required": true, - "type": "password", - "bindTime": true, - "description": "The Watson service password" - } -]' \ - -a sampleInput '{"payload":"<base64 encoding of a wav file>", "encoding":"base64", "content_type":"audio/wav", "username":"XXX", "password":"XXX"}' \ - -a sampleOutput '{"data":"Hello."}' - - -install "$PACKAGE_HOME/watson-textToSpeech/textToSpeech.js" \ - watson-textToSpeech/textToSpeech \ - -a description 'Synthesize text to spoken audio' \ - -a parameters '[ - {"name":"username", "required":true, "bindTime":true, "description":"The Watson service username"}, - {"name":"password", "required":true, "type":"password", "bindTime":true, "description":"The Watson service password"}, - {"name":"payload", "required":true, "description":"The text to be synthesized"}, - {"name":"voice", "required":false, "description":"The voice to be used for synthesis"}, - {"name":"accept", "required":false, "description":"The requested MIME type of the audio"}, - {"name":"encoding", "required":false, "description":"The encoding of the speech binary data"}]' \ - -a sampleInput '{"payload":"Hello, world.", "encoding":"base64", "accept":"audio/wav", "voice":"en-US_MichaelVoice", "username":"XXX", "password":"XXX" }' \ - -a sampleOutput '{"payload":"<base64 encoding of a .wav file>", "encoding":"base64", "mimetype":"audio/wav"}' - -waitForAll - -echo Watson package ERRORS = $ERRORS -exit $ERRORS diff --git a/packages/watson-speechToText/README.md b/packages/watson-speechToText/README.md deleted file mode 100644 index f45932f..0000000 --- a/packages/watson-speechToText/README.md +++ /dev/null @@ -1,102 +0,0 @@ -<!-- -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---> - -# Using the Watson Speech to Text package - -The `/whisk.system/watson-speechToText` package offers a convenient way to call Watson APIs to convert the speech into text. - -The package includes the following actions. - -| Entity | Type | Parameters | Description | -| --- | --- | --- | --- | -| `/whisk.system/watson-speechToText` | package | username, password | Package to convert speech into text | -| `/whisk.system/watson-speechToText/speechToText` | action | payload, content_type, encoding, username, password, continuous, inactivity_timeout, interim_results, keywords, keywords_threshold, max_alternatives, model, timestamps, watson-token, word_alternatives_threshold, word_confidence, X-Watson-Learning-Opt-Out | Convert audio into text | - -**Note**: The package `/whisk.system/watson` is deprecated including the action `/whisk.system/watson/speechToText`. - -## Setting up the Watson Speech to Text package in Bluemix - -If you're using OpenWhisk from Bluemix, OpenWhisk automatically creates package bindings for your Bluemix Watson service instances. - -1. Create a Watson Speech to Text service instance in your Bluemix [dashboard](http://console.ng.Bluemix.net). - - Be sure to remember the name of the service instance and the Bluemix organization and space you're in. - -2. Refresh the packages in your namespace. The refresh automatically creates a package binding for the Watson service instance that you created. - - ``` - wsk package refresh - ``` - ``` - created bindings: - Bluemix_Watson_SpeechToText_Credentials-1 - ``` - ``` - wsk package list - ``` - ``` - packages - /myBluemixOrg_myBluemixSpace/Bluemix_Watson_SpeechToText_Credentials-1 private - ``` - - -## Setting up a Watson Speech to Text package outside Bluemix - -If you're not using OpenWhisk in Bluemix or if you want to set up your Watson Speech to Text outside of Bluemix, you must manually create a package binding for your Watson Speech to Text service. You need the Watson Speech to Text 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-speechToText myWatsonSpeechToText -p username MYUSERNAME -p password MYPASSWORD - ``` - - -## Converting speech to text - -The `/whisk.system/watson-speechToText/speechToText` action converts audio speech into text. The parameters are as follows: - -- `username`: The Watson API user name. -- `password`: The Watson API password. -- `payload`: The encoded speech binary data to turn into text. -- `content_type`: The MIME type of the audio. -- `encoding`: The encoding of the speech binary data. -- `continuous`: Indicates whether multiple final results that represent consecutive phrases that are separated by long pauses are returned. -- `inactivity_timeout`: The time in seconds after which, if only silence is detected in submitted audio, the connection is closed. -- `interim_results`: Indicates whether the service is to return interim results. -- `keywords`: A list of keywords to spot in the audio. -- `keywords_threshold`: A confidence value that is the lower bound for spotting a keyword. -- `max_alternatives`: The maximum number of alternative transcripts to be returned. -- `model`: The identifier of the model to be used for the recognition request. -- `timestamps`: Indicates whether time alignment is returned for each word. -- `watson-token`: Provides an authentication token for the service as an alternative to providing service credentials. -- `word_alternatives_threshold`: A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative. -- `word_confidence`: Indicates whether a confidence measure in the range of 0 to 1 is to be returned for each word. -- `X-Watson-Learning-Opt-Out`: Indicates whether to opt out of data collection for the call. - - -- Invoke the `speechToText` action in your package binding to convert the encoded audio. - - ``` - wsk action invoke myWatsonSpeechToText/speechToText --blocking --result --param payload <base64 encoding of a .wav file> --param content_type 'audio/wav' --param encoding 'base64' - ``` - ```json - { - "data": "Hello Watson" - } - ``` diff --git a/packages/watson-speechToText/manifest.yaml b/packages/watson-speechToText/manifest.yaml deleted file mode 100644 index 5bcb1da..0000000 --- a/packages/watson-speechToText/manifest.yaml +++ /dev/null @@ -1,151 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -project: - name: WhiskSystem - packages: - watson-speechToText: - license: Apache-2.0 - version: 0.0.1 - public: true - annotations: - description: Actions for the Watson analytics APIs to convert speech into text - parameters: [ - { - "name": "bluemixServiceName", - "required": false, - "bindTime": true - }, - { - "name": "username", - "required": false - }, - { - "name": "password", - "required": false, - "type": "password" - } - ] - tags: [ "watson" ] - inputs: - bluemixServiceName: - value: speech_to_text - actions: - speechToText: - version: 0.0.1 - function: speechToText.js - runtime: nodejs:6 - annotations: - description: Post a message to Slack - sampleInput: { - "payload": "<base64 encoding of a wav file>", - "encoding": "base64", - "content_type": "audio/wav", - "username": "XXX", - "password": "XXX" - } - sampleOutput: { "data": "Hello." } - parameters: [ - { - "name": "content_type", - "required": true, - "description": "The MIME type of the audio" - }, - { - "name": "model", - "required": false, - "description": "The identifier of the model to be used for the recognition request" - }, - { - "name": "continuous", - "required": false, - "description": "Indicates whether multiple final results that represent consecutive phrases separated by long pauses are returned" - }, - { - "name": "inactivity_timeout", - "required": false, - "description": "The time in seconds after which, if only silence (no speech) is detected in submitted audio, the connection is closed" - }, - { - "name": "interim_results", - "required": false, - "description": "Indicates whether the service is to return interim results" - }, - { - "name": "keywords", - "required": false, - "description": "A list of keywords to spot in the audio" - }, - { - "name": "keywords_threshold", - "required": false, - "description": "A confidence value that is the lower bound for spotting a keyword" - }, - { - "name": "max_alternatives", - "required": false, - "description": "The maximum number of alternative transcripts to be returned" - }, - { - "name": "word_alternatives_threshold", - "required": false, - "description": "A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative" - }, - { - "name": "word_confidence", - "required": false, - "description": "Indicates whether a confidence measure in the range of 0 to 1 is to be returned for each word" - }, - { - "name": "timestamps", - "required": false, - "description": "Indicates whether time alignment is returned for each word" - }, - { - "name": "X-Watson-Learning-Opt-Out", - "required": false, - "description": "Indicates whether to opt out of data collection for the call" - }, - { - "name": "watson-token", - "required": false, - "description": "Provides an authentication token for the service as an alternative to providing service credentials" - }, - { - "name": "encoding", - "required": true, - "description": "The encoding of the speech binary data" - }, - { - "name": "payload", - "required": true, - "description": "The encoding of the speech binary data" - }, - { - "name": "username", - "required": true, - "bindTime": true, - "description": "The Watson service username" - }, - { - "name": "password", - "required": true, - "type": "password", - "bindTime": true, - "description": "The Watson service password" - } - ] - diff --git a/packages/watson-speechToText/speechToText.js b/packages/watson-speechToText/speechToText.js deleted file mode 100644 index 861788d..0000000 --- a/packages/watson-speechToText/speechToText.js +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var watson = require('watson-developer-cloud'); -var fs = require('fs'); -var stream = require('stream'); - -function isValidEncoding(encoding) { - return encoding === 'ascii' || - encoding === 'utf8' || - encoding === 'utf16le' || - encoding === 'ucs2' || - encoding === 'base64' || - encoding === 'binary' || - encoding === 'hex'; -} - -/** - * Transcribes speech from various languages and audio formats to text - * See https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/speech-to-text/api/v1/#recognize_audio_websockets - * - * @param content_type The MIME type of the audio. Required. - * @param model The identifier of the model to be used for the recognition request. - * @param continuous Indicates whether multiple final results that represent consecutive phrases separated by long pauses are returned. - * @param inactivity_timeout The time in seconds after which, if only silence (no speech) is detected in submitted audio, the connection is closed. The default is 30 seconds. - * @param interim_results Indicates whether the service is to return interim results. - * @param keywords A list of keywords to spot in the audio. - * @param keywords_threshold A confidence value that is the lower bound for spotting a keyword. - * @param max_alternatives The maximum number of alternative transcripts to be returned. - * @param word_alternatives_threshold A confidence value that is the lower bound for identifying a hypothesis as a possible word alternative. - * @param word_confidence Indicates whether a confidence measure in the range of 0 to 1 is to be returned for each word. - * @param timestamps Indicates whether time alignment is returned for each word. - * @param X-Watson-Learning-Opt-Out Indicates whether to opt out of data collection for the call. - * @param watson-token Provides an authentication token for the service as an alternative to providing service credentials. - * @param encoding The encoding of the speech binary data. Required. - * @param payload The encoded data to turn into text. Required. - * @param username The Watson service username. - * @param password The Watson service password. - * - * @return { - * "data": "Final results for the request", - * "results": "Interim results for the request" - * "error": "Errors for the connection" - * } - */ -function main(params) { - var payload = params.payload; - var encoding = params.encoding; - var username = params.username; - var password = params.password; - - console.log('params:', params); - - if (!payload) { - return { - 'error': 'No payload specified.' - }; - } else if (!isValidEncoding(encoding)) { - return { - 'error': 'Not a valid encoding.' - }; - } - - var response = {}; - var speechToText = watson.speech_to_text({ - username: username, - password: password, - version: 'v1' - }); - - // Create the stream. - var recognizeStream = speechToText.createRecognizeStream({ - content_type: params.content_type, - model: params.model, - continuous: params.continuous, - inactivity_timeout: params.inactivity_timeout, - interim_results: params.interim_results, - keywords: params.keywords, - max_alternatives: params.max_alternatives, - word_alternatives_threshold: params.word_alternatives_threshold, - word_confidence: params.word_confidence, - timestamps: params.timestamps, - 'X-Watson-Learning-Opt-Out': params['X-Watson-Learning-Opt-Out'], - 'watson-token': params['watson-token'] - }); - - // Pipe in some audio. - var b = Buffer(payload, encoding); - var s = new stream.Readable(); - s._read = function noop() {}; // Needed to escape not implemented exception - s.push(b); - s.pipe(recognizeStream); - s.push(null); - - // Pipe out the transcription. - recognizeStream.pipe(fs.createWriteStream('output')); - - // Get strings instead of buffers from `data` events. - recognizeStream.setEncoding('utf8'); - - // Listen for 'data' events for only the final results. - // Listen for 'results' events to get interim results. - var promise = new Promise(function(resolve, reject) { - ['data', 'results', 'error', 'connection-close'].forEach(function (name) { - recognizeStream.on(name, function (event_) { - if (name === 'data') { - response.data = event_; - resolve(response); - } else if (name === 'results' && params.interim_results) { - if (!response.results) { - response.results = []; - } - response.results.push(event_); - } else if (name === 'error' || name === 'connection-close') { - response.error = event_ && typeof(event_.toString) === 'function' ? - event_.toString() : 'Watson API failed'; - resolve(response); - } - }); - }); - }); - - return promise; -} - diff --git a/packages/watson-textToSpeech/README.md b/packages/watson-textToSpeech/README.md deleted file mode 100644 index 3e4d451..0000000 --- a/packages/watson-textToSpeech/README.md +++ /dev/null @@ -1,91 +0,0 @@ -<!-- -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---> - -# Using the Watson Text to Speech package - -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`. - -## Setting up the Watson Text to Speech package in Bluemix - -If you're using OpenWhisk from Bluemix, OpenWhisk automatically creates package bindings for your Bluemix Watson service instances. - -1. Create a Watson Text to Speech service instance in your Bluemix [dashboard](http://console.ng.Bluemix.net). - - Be sure to remember the name of the service instance and the Bluemix organization and space you're in. - -2. Refresh the packages in your namespace. The refresh automatically creates a package binding for the Watson service instance that you created. - - ``` - wsk package refresh - ``` - ``` - created bindings: - Bluemix_Watson_TextToSpeech_Credentials-1 - ``` - ``` - wsk package list - ``` - ``` - packages - /myBluemixOrg_myBluemixSpace/Bluemix_Watson_TextToSpeec_Credentials-1 private - ``` - - -## Setting up a Watson Text to Speech package outside Bluemix - -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 - ``` - - -## Converting some text to speech - -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' - ``` - ```json - { - "payload": "<base64 encoding of a .wav file>" - } - ``` diff --git a/packages/watson-textToSpeech/manifest.yaml b/packages/watson-textToSpeech/manifest.yaml deleted file mode 100644 index 4c20fc0..0000000 --- a/packages/watson-textToSpeech/manifest.yaml +++ /dev/null @@ -1,101 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one or more -# contributor license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright ownership. -# The ASF licenses this file to You under the Apache License, Version 2.0 -# (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -project: - name: WhiskSystem - packages: - watson-textToSpeech: - license: Apache-2.0 - version: 0.0.1 - public: true - annotations: - description: "Actions for the Watson analytics APIs to convert text into speech" - parameters: [ - { - "name": "bluemixServiceName", - "required": false, - "bindTime": true - }, - { - "name": "username", - "required": false - }, - { - "name": "password", - "required": false, - "type": "password" - } - ] - tags: [ "watson" ] - inputs: - bluemixServiceName: - value: text_to_speech - actions: - textToSpeech: - version: 0.0.1 - function: textToSpeech.js - runtime: nodejs:6 - annotations: - description: "Synthesize text to spoken audio" - sampleInput: { - "payload":"Hello, world.", - "encoding":"base64", - "accept":"audio/wav", - "voice":"en-US_MichaelVoice", - "username":"XXX", - "password":"XXX" - } - sampleOutput: { - "payload":"<base64 encoding of a .wav file>", - "encoding":"base64", - "mimetype":"audio/wav" - } - parameters: [ - { - "name": "username", - "required": true, - "bindTime": true, - "description": "The Watson service username" - }, - { - "name": "password", - "required": true, - "type": "password", - "bindTime": true, - "description": "The Watson service password" - }, - { - "name": "payload", - "required": true, - "description": "The text to be synthesized" - }, - { - "name":"voice", - "required":false, - "description":"The voice to be used for synthesis" - }, - { - "name":"accept", - "required":false, - "description":"The requested MIME type of the audio" - }, - { - "name": "encoding", - "required": false, - "description": "The encoding of the speech binary data" - }, - ] - diff --git a/packages/watson-textToSpeech/textToSpeech.js b/packages/watson-textToSpeech/textToSpeech.js deleted file mode 100644 index 983cb83..0000000 --- a/packages/watson-textToSpeech/textToSpeech.js +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -var watson = require('watson-developer-cloud'); - -function isValidEncoding(encoding) { - return encoding === 'ascii' || - encoding === 'utf8' || - encoding === 'utf16le' || - encoding === 'ucs2' || - encoding === 'base64' || - encoding === 'binary' || - encoding === 'hex'; -} - -/** - * Synthesizes text to spoken audio. - * See https://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/text-to-speech/api/v1/ - * - * @param voice The voice to be used for synthesis. Example: en-US_MichaelVoice - * @param accept The requested MIME type of the audio. Example: audio/wav - * @param payload The text to synthesized. Required. - * @param encoding The encoding of the speech binary data. Defaults to base64. - * @param username The Watson service username. - * @param password The Watson service password. - * - * @return { - * "payload": "<encoded speech file>", - * "encoding": "<encoding of payload>", - * "content_type": "<content_type of payload>" - * } - */ -function main(params) { - var voice = params.voice; - var accept = params.accept; - var payload = params.payload; - var encoding = isValidEncoding(params.encoding) ? params.encoding : 'base64'; - var username = params.username; - var password = params.password; - - console.log('params:', params); - - var textToSpeech = watson.text_to_speech({ - username: username, - password: password, - version: 'v1' - }); - - var promise = new Promise(function(resolve, reject) { - textToSpeech.synthesize({ - voice: voice, - accept: accept, - text: payload, - }, function (err, res) { - if (err) { - reject(err); - } else { - resolve({ - payload: res.toString(encoding), - encoding: encoding, - mimetype: accept - }); - } - }, function (err) { - reject(err); - }); - }); - - return promise; -} - diff --git a/packages/weather/README.md b/packages/weather/README.md index b0911d1..52fd746 100644 --- a/packages/weather/README.md +++ b/packages/weather/README.md @@ -60,7 +60,7 @@ If you're using OpenWhisk from Bluemix, OpenWhisk automatically creates package If you're not using OpenWhisk in Bluemix or if you want to set up your Weather Company Data service outside of Bluemix, you must manually create a package binding for your WWeather Company Data service. You need the Weather Company Data service user name, and password. -- Create a package binding that is configured for your Watson Translator service. +- Create a package binding that is configured for your Weather Company Data service. ``` wsk package bind /whisk.system/weather myWeather -p username MYUSERNAME -p password MYPASSWORD diff --git a/tests/build.gradle b/tests/build.gradle index 84926c5..991417b 100644 --- a/tests/build.gradle +++ b/tests/build.gradle @@ -34,7 +34,6 @@ tasks.withType(Test) { } task testWithoutCredentials(type: Test) { - exclude 'packages/watson/**' exclude 'packages/slack/**' exclude 'packages/weather/**' } diff --git a/tests/src/test/scala/packages/watson/WatsonTests.scala b/tests/src/test/scala/packages/watson/WatsonTests.scala deleted file mode 100644 index b472302..0000000 --- a/tests/src/test/scala/packages/watson/WatsonTests.scala +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package packages.watson - -import org.junit.runner.RunWith -import org.scalatest.BeforeAndAfterAll -import org.scalatest.junit.JUnitRunner - -import common.TestHelpers -import common.Wsk -import common.WskProps -import common.WskTestHelpers -import common.TestUtils -import spray.json.DefaultJsonProtocol._ -import spray.json._ - -@RunWith(classOf[JUnitRunner]) -class WatsonTests - extends TestHelpers - with WskTestHelpers - with BeforeAndAfterAll { - - implicit val wskprops = WskProps() - val wsk = new Wsk() - - behavior of "Watson actions" - - - it should "convert the text into speech via the Watson textToSpeech API and convert the speech back to the same text via via the Watson speechToText API" in { - var credentials = TestUtils.getVCAPcredentials("text_to_speech") - var username = credentials.get("username") - var password = credentials.get("password") - val textToSpeechAction = "/whisk.system/watson-textToSpeech/textToSpeech" - val speech = "hello watson" - var results = s"" - var run = wsk.action.invoke(textToSpeechAction, Map("username" -> username.toJson, "password" -> password.toJson, - "payload" -> speech.toJson, "accept" -> "audio/wav".toJson, "encoding" -> "base64".toJson)) - withActivation(wsk.activation, run) { - activation => - activation.response.success shouldBe true - results = activation.response.result.get.fields.get("payload").get.toString - } - - credentials = TestUtils.getVCAPcredentials("speech_to_text") - username = credentials.get("username") - password = credentials.get("password") - val speechToTextAction = "/whisk.system/watson-speechToText/speechToText" - run = wsk.action.invoke(speechToTextAction, Map("username" -> username.toJson, "password" -> password.toJson, - "payload" -> results.toJson, "content_type" -> "audio/wav".toJson, "encoding" -> "base64".toJson)) - withActivation(wsk.activation, run) { - activation => - activation.response.success shouldBe true - activation.response.result.get.fields.get("data").toString.toLowerCase should include(speech) - } - } -}