Skip to content
This repository has been archived by the owner on Jan 7, 2021. It is now read-only.

Commit

Permalink
Update README, travis, add casper
Browse files Browse the repository at this point in the history
  • Loading branch information
germanattanasio committed Nov 22, 2016
1 parent 3ed0070 commit fba5770
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 93 deletions.
21 changes: 9 additions & 12 deletions .travis.yml
@@ -1,8 +1,13 @@
language: node_js
sudo: true
node_js: stable
dist: trusty
sudo: required
node_js: 6
script:
- npm run codecov
- npm run test

cache:
directories:
- node_modules
env:
global:
- CF_APP=text-to-speech-demo
Expand All @@ -13,18 +18,10 @@ before_deploy: npm install -g cf-blue-green
deploy:
provider: script
script:
- cf-blue-green-travis
- cf-blue-green-travis
on:
branch: master
repo: watson-developer-cloud/text-to-speech-nodejs
skip_cleanup: true
provider: script
script:
- CF_APP=text-to-speech-qa cf-blue-green-travis
on:
branch: react-jbs
repo: watson-developer-cloud/text-to-speech-nodejs
skip_cleanup: true

notifications:
email: false
115 changes: 60 additions & 55 deletions README.md
Expand Up @@ -2,8 +2,6 @@

The IBM Watson [Text to Speech][service_url] service is designed for streaming, low latency, synthesis of audio from text. It is the inverse of the automatic speech recognition.

Give it a try! Click the button below to fork into IBM DevOps Services and deploy your own copy of this application on Bluemix.

[![Deploy to Bluemix](https://bluemix.net/deploy/button.png)](https://bluemix.net/deploy?repository=https://github.com/watson-developer-cloud/text-to-speech-nodejs)

## Getting started
Expand All @@ -14,91 +12,82 @@ Give it a try! Click the button below to fork into IBM DevOps Services and deplo

1. Edit the `manifest.yml` file and change `<application-name>` to something unique. The name you use determines the URL of your application. For example, `<application-name>.mybluemix.net`.

```yaml
```yaml
applications:
- services:
- my-text-to-speech
- my-service-instance
name: <application-name>
command: npm start
path: .
memory: 512M
```
```

1. Connect to Bluemix with the command line tool.

```sh
$ cf api https://api.ng.bluemix.net
$ cf login -u <your user ID>
```

1. Create the Text to Speech service in Bluemix.

```sh
$ cf create-service text_to_speech standard my-text-to-speech
```
```sh
cf api https://api.ng.bluemix.net
cf login
```

1. Push your app to make it live:
1. Create and retrieve service keys to access the [Text to Speech][service_url] service:

```sh
$ cf push
```
```none
cf create-service text_to_speech standard my-tts-service
cf create-service-key my-tts-service myKey
cf service-key my-tts-service myKey
```

For more details about developing applications that use Watson Developer Cloud services in Bluemix, see [Getting started with Watson Developer Cloud and Bluemix][getting_started].
1. Create a `.env` file in the root directory by copying the sample `.env.example` file using the following command:

## Running locally
```none
cp .env.example .env
```
You will update the `.env` with the information you retrieved in steps 5.

1. Download and install [Node.js](http://nodejs.org/) and [npm](https://www.npmjs.com/).
The `.env` file will look something like the following:

1. Create an instance of the Text to Speech service on Bluemix.
```none
TEXT_TO_SPEECH_USERNAME=<username>
TEXT_TO_SPEECH_PASSWORD=<password>
```

1. Configure the code to connect to your service:
1. Install the dependencies you application need:

1. Copy the credentials from your Text to Speech service in Bluemix. Run the following command:
```none
npm install
```

```sh
$ cf service-key my-text-to-speech Credentials-1
```
1. Start the application locally:

Example output:
```none
npm start
```

```sh
{"password": "<password>",
"url": "<url>",
"username": "<username>"
}
```
1. Point your browser to [http://localhost:3000](http://localhost:3000).

1. You can add that information to Rename `.env.example` to be `.env` and update it with `username`, `password`.
1. **Optional:** Push the application to Bluemix:

```none
TEXT_TO_SPEECH_USERNAME=
TEXT_TO_SPEECH_PASSWORD=
```none
cf push
```

1. Install the dependencies:
After completing the steps above, you are ready to test your application. Start a browser and enter the URL of your application.

```sh
$ npm install
```
<your application name>.mybluemix.net

1. Start the application:

```sh
npm start
```

1. Point your browser to [http://localhost:3000](http://localhost:3000).
For more details about developing applications that use Watson Developer Cloud services in Bluemix, see [Getting started with Watson Developer Cloud and Bluemix][getting_started].


## Troubleshooting

* The main source of troubleshooting and recovery information is the Bluemix log. To view the log, run the following command:

```sh
$ cf logs <application-name> --recent
cf logs <application-name> --recent
```

* For more details about the service, see the [documentation][nlc_docs] for the Natural Language Classifier.
* For more details about the service, see the [documentation][docs] for the Text to Speech service.


----
Expand All @@ -109,14 +98,14 @@ Give it a try! Click the button below to fork into IBM DevOps Services and deplo
.
├── app.js // express routes
├── config // express configuration
   ├── error-handler.js
   ├── express.js
   └── security.js
├── error-handler.js
├── express.js
└── security.js
├── manifest.yml
├── package.json
├── public // static resources
├── server.js // entry point
├── test // unit tests
├── test // tests
└── views // react components
```

Expand All @@ -131,8 +120,24 @@ Give it a try! Click the button below to fork into IBM DevOps Services and deplo
## Open Source @ IBM
Find more open source projects on the [IBM Github Page](http://ibm.github.io/)

## Privacy Notice

Sample web applications that include this package may be configured to track deployments to [IBM Bluemix](https://www.bluemix.net/) and other Cloud Foundry platforms. The following information is sent to a [Deployment Tracker](https://github.com/IBM-Bluemix/cf-deployment-tracker-service) service on each deployment:

* Node.js package version
* Node.js repository URL
* Application Name (`application_name`)
* Space ID (`space_id`)
* Application Version (`application_version`)
* Application URIs (`application_uris`)
* Labels of bound services
* Number of instances for each bound service and associated plan information

This data is collected from the `package.json` file in the sample application and the `VCAP_APPLICATION` and `VCAP_SERVICES` environment variables in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM to track metrics around deployments of sample applications to IBM Bluemix to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.

[deploy_track_url]: https://github.com/cloudant-labs/deployment-tracker
[cloud_foundry]: https://github.com/cloudfoundry/cli
[getting_started]: https://www.ibm.com/watson/developercloud/doc/getting_started/
[service_url]: http://www.ibm.com/watson/developercloud/text-to-speech.html
[docs]: http://www.ibm.com/watson/developercloud/text-to-speech/
[sign_up]: https://console.ng.bluemix.net/registration/
55 changes: 55 additions & 0 deletions casper-runner.js
@@ -0,0 +1,55 @@
/**
* Copyright 2015 IBM Corp. All Rights Reserved.
*
* Licensed 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.
*/

const fs = require('fs');
if (!fs.existsSync('.env')) {
return;
}
const spawn = require('child_process').spawn;

require('dotenv').config();

const app = require('./app');
const port = 3000;

const server = app.listen(port, () => {
// eslint-disable-next-line no-console
console.log('Server running on port: %d', port);

function kill(code) {
server.close(() => {
// eslint-disable-next-line no-process-exit
process.exit(code);
});
}

function runTests() {
const casper = spawn('npm', ['run', 'test-integration']);
casper.stdout.pipe(process.stdout);

casper.on('error', (error) => {
// eslint-disable-next-line no-console
console.log(`ERROR: ${error}`);
server.close(() => {
process.exit(1);
});
});

casper.on('close', kill);
}

runTests();
});
2 changes: 1 addition & 1 deletion config/security.js
Expand Up @@ -27,7 +27,7 @@ module.exports = function (app) {
const limiter = rateLimit({
windowMs: 60 * 1000, // seconds
delayMs: 0,
max: 5,
max: 4,
message: JSON.stringify({
error: 'Too many requests, please try again in 30 seconds.',
code: 429,
Expand Down
17 changes: 10 additions & 7 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "text-to-speech-demo",
"version": "2.0.0",
"description": "Text to Speech sample application",
"description": "IBM Watson Text to Speech sample application",
"engines": {
"node": ">=6.0",
"npm": ">3.0"
Expand Down Expand Up @@ -30,27 +30,29 @@
"express-rate-limit": "^2.3.1",
"express-react-views": "^0.10.2",
"express-secure-only": "^0.2.1",
"helmet": "^2.1.1",
"helmet": "^3.1.0",
"morgan": "^1.7.0",
"react": "^15.3.1",
"react-addons-pure-render-mixin": "^15.3.2",
"react-dom": "^15.3.2",
"uglifyify": "^3.0.3",
"watson-developer-cloud": "^2.4.2",
"watson-react-components": "^0.0.19",
"watson-react-components": "^0.1.0",
"watson-ui-components": "^0.5.3",
"whatwg-fetch": "^1.0.0"
"whatwg-fetch": "^2.0.1"
},
"scripts": {
"start": "node server.js",
"test": "npm run lint && npm run smoketest",
"integration-test" : "npm run lint && casperjs test ./test/integration/test.*.js",
"smoketest": "istanbul cover ./node_modules/mocha/bin/_mocha",
"test-integration": "casperjs test ./test/integration/test.*.js",
"test-integration-runner": "NODE_ENV=test node casper-runner.js",
"test": "npm run lint && npm run test-unit && npm run test-integration-runner",
"test-unit": "istanbul cover ./node_modules/mocha/bin/_mocha test/unit",
"lint": "eslint .",
"autofix": "eslint --fix .",
"codecov": "npm run test && (codecov || true)"
},
"devDependencies": {
"casperjs": "^1.1.3",
"codecov": "^1.0.1",
"eslint": "^3.3.1",
"eslint-config-airbnb": "^10.0.1",
Expand All @@ -59,6 +61,7 @@
"eslint-plugin-react": "^6.3.0",
"istanbul": "^0.4.2",
"mocha": "^3.1.0",
"phantomjs-prebuilt": "^2.1.13",
"supertest": "^2.0.0"
},
"babel": {
Expand Down

0 comments on commit fba5770

Please sign in to comment.