|
1 | | -# Speech to Text Browser Application |
| 1 | +<h1 align="center" style="border-bottom: none;">🎤 Speech to Text Demo </h1> |
| 2 | +<h3 align="center">Node.js sample applications that shows some of the the IBM Watson Speech to Text service features.</h3> |
| 3 | +<p align="center"> |
| 4 | + <a href="http://travis-ci.org/watson-developer-cloud/speech-to-text-nodejs"> |
| 5 | + <img alt="Travis" src="https://travis-ci.org/watson-developer-cloud/speech-to-text-nodejs.svg?branch=master"> |
| 6 | + </a> |
| 7 | + <a href="#badge"> |
| 8 | + <img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg"> |
| 9 | + </a> |
| 10 | +</p> |
| 11 | +</p> |
2 | 12 |
|
3 | | -[](https://travis-ci.org/watson-developer-cloud/speech-to-text-nodejs) |
| 13 | +The [Speech to Text][service_url] service uses IBM's speech recognition capabilities to convert speech in multiple languages into text. The transcription of incoming audio is continuously sent back to the client with minimal delay, and it is corrected as more speech is heard. The service is accessed via a WebSocket interface; a REST HTTP interface is also available; |
4 | 14 |
|
5 | | - The [Speech to Text][service_url] service uses IBM's speech recognition capabilities to convert speech in multiple languages into text. The transcription of incoming audio is continuously sent back to the client with minimal delay, and it is corrected as more speech is heard. The service is accessed via a WebSocket interface; a REST HTTP interface is also available; |
| 15 | +You can view a [demo][demo_url] of this app. |
6 | 16 |
|
7 | | -Node.js is also used to provide the browser client's authentication token. |
| 17 | +## Prerequisites |
8 | 18 |
|
9 | | -[](https://bluemix.net/deploy?repository=https://github.com/watson-developer-cloud/speech-to-text-nodejs) |
| 19 | +1. Sign up for an [IBM Cloud account](https://console.bluemix.net/registration/). |
| 20 | +1. Download the [IBM Cloud CLI](https://console.bluemix.net/docs/cli/index.html#overview). |
| 21 | +1. Create an instance of the Speech to Text service and get your credentials: |
| 22 | + - Go to the [Speech to Text](https://console.bluemix.net/catalog/services/speech-to-text) page in the IBM Cloud Catalog. |
| 23 | + - Log in to your IBM Cloud account. |
| 24 | + - Click **Create**. |
| 25 | + - Click **Show** to view the service credentials. |
| 26 | + - Copy the `apikey` value, or copy the `username` and `password` values if your service instance doesn't provide an `apikey`. |
| 27 | + - Copy the `url` value. |
10 | 28 |
|
11 | | -## Getting started |
| 29 | +## Configuring the application |
12 | 30 |
|
13 | | -1. You need a Bluemix account. If you don't have one, [sign up][sign_up]. |
| 31 | +1. In the application folder, copy the *.env.example* file and create a file called *.env* |
14 | 32 |
|
15 | | -2. Download and install the [Cloud-foundry CLI][cloud_foundry] tool if you haven't already. |
| 33 | + ``` |
| 34 | + cp .env.example .env |
| 35 | + ``` |
16 | 36 |
|
17 | | -3. 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`. |
| 37 | +2. Open the *.env* file and add the service credentials that you obtained in the previous step. |
18 | 38 |
|
19 | | - ```yaml |
20 | | - applications: |
21 | | - - services: |
22 | | - - my-service-instance |
23 | | - name: <application-name> |
24 | | - command: npm start |
25 | | - path: . |
26 | | - memory: 512M |
27 | | - ``` |
| 39 | + Example *.env* file that configures the `apikey` and `url` for a Speech to Text service instance hosted in the US East region: |
28 | 40 |
|
29 | | -4. Connect to Bluemix with the command line tool. |
| 41 | + ``` |
| 42 | + SPEECH_TO_TEXT_IAM_APIKEY=X4rbi8vwZmKpXfowaS3GAsA7vdy17Qh7km5D6EzKLHL2 |
| 43 | + SPEECH_TO_TEXT_URL=https://stream-wdc.watsonplatform.net/speech-to-text/api |
| 44 | + ``` |
30 | 45 |
|
31 | | - ```sh |
32 | | - cf api https://api.ng.bluemix.net |
33 | | - cf login |
34 | | - ``` |
| 46 | + - If your service instance uses `username` and `password` credentials, add the `SPEECH_TO_TEXT_USERNAME` and `SPEECH_TO_TEXT_PASSWORD` variables to the *.env* file. |
35 | 47 |
|
36 | | -5. Create and retrieve service keys to access the [Speech to Text][service_url] service: |
| 48 | + Example *.env* file that configures the `username`, `password`, and `url` for a Speech to Text service instance hosted in the Sydney region: |
37 | 49 |
|
38 | | - ```none |
39 | | - cf create-service speech_to_text standard my-stt-service |
40 | | - cf create-service-key my-stt-service myKey |
41 | | - cf service-key my-stt-service myKey |
42 | | - ``` |
| 50 | + ``` |
| 51 | + SPEECH_TO_TEXT_USERNAME=522be-7b41-ab44-dec3-g1eab2ha73c6 |
| 52 | + SPEECH_TO_TEXT_PASSWORD=A4Z5BdGENrwu8 |
| 53 | + SPEECH_TO_TEXT_URL=https://gateway-syd.watsonplatform.net/speech-to-text/api |
| 54 | + ``` |
43 | 55 |
|
44 | | -6. Create a `.env` file in the root directory by copying the sample `.env.example` file using the following command: |
| 56 | +## Running locally |
45 | 57 |
|
46 | | - ```none |
47 | | - cp .env.example .env |
48 | | - ``` |
49 | | - You will update the `.env` with the information you retrieved in steps 5. |
| 58 | +1. Install the dependencies |
50 | 59 |
|
51 | | - The `.env` file will look something like the following: |
| 60 | + ``` |
| 61 | + npm install |
| 62 | + ``` |
52 | 63 |
|
53 | | - ```none |
54 | | - SPEECH_TO_TEXT_USERNAME=<username> |
55 | | - SPEECH_TO_TEXT_PASSWORD=<password> |
56 | | - ``` |
| 64 | +1. Run the application |
57 | 65 |
|
58 | | -7. Install the dependencies you application need: |
| 66 | + ``` |
| 67 | + npm start |
| 68 | + ``` |
59 | 69 |
|
60 | | - ```none |
61 | | - npm install |
62 | | - ``` |
| 70 | +1. View the application in a browser at `localhost:3000` |
63 | 71 |
|
64 | | -8. Start the application locally: |
| 72 | +## Deploying to IBM Cloud as a Cloud Foundry Application |
65 | 73 |
|
66 | | - ```none |
67 | | - npm start |
68 | | - ``` |
| 74 | +1. Login to IBM Cloud with the [IBM Cloud CLI](https://console.bluemix.net/docs/cli/index.html#overview) |
69 | 75 |
|
70 | | -9. Point your browser to [http://localhost:3000](http://localhost:3000). |
| 76 | + ``` |
| 77 | + ibmcloud login |
| 78 | + ``` |
71 | 79 |
|
72 | | -10. **Optional:** Push the application to Bluemix: |
| 80 | +1. Target a Cloud Foundry organization and space. |
73 | 81 |
|
74 | | - ```none |
75 | | - cf push |
76 | | - ``` |
| 82 | + ``` |
| 83 | + ibmcloud target --cf |
| 84 | + ``` |
77 | 85 |
|
78 | | -After completing the steps above, you are ready to test your application. Start a browser and enter the URL of your application. |
| 86 | +1. Edit the *manifest.yml* file. Change the **name** field to something unique. For example, `- name: my-app-name`. |
| 87 | +1. Deploy the application |
79 | 88 |
|
80 | | - <your application name>.mybluemix.net |
| 89 | + ``` |
| 90 | + ibmcloud app push |
| 91 | + ``` |
81 | 92 |
|
| 93 | +1. View the application online at the app URL, for example: https://my-app-name.mybluemix.net |
82 | 94 |
|
83 | | -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]. |
84 | | - |
85 | | - |
86 | | -## Troubleshooting |
87 | | - |
88 | | -* The main source of troubleshooting and recovery information is the Bluemix log. To view the log, run the following command: |
89 | | - |
90 | | - ```sh |
91 | | - cf logs <application-name> --recent |
92 | | - ``` |
93 | | - |
94 | | -* For more details about the service, see the [documentation][docs] for the Speech to Text service. |
95 | | - |
96 | | - |
97 | | ----- |
98 | | - |
99 | | -### Directory structure |
100 | | - |
101 | | -```none |
102 | | -. |
103 | | -├── app.js // express routes |
104 | | -├── config // express configuration |
105 | | -│ ├── express.js |
106 | | -│ └── security.js |
107 | | -├── manifest.yml |
108 | | -├── package.json |
109 | | -├── public // static resources |
110 | | -├── server.js // entry point |
111 | | -├── test // tests |
112 | | -└── views // react components |
113 | | -``` |
114 | 95 |
|
115 | 96 | ## License |
116 | 97 |
|
117 | 98 | This sample code is licensed under Apache 2.0. |
118 | 99 |
|
119 | 100 | ## Contributing |
120 | 101 |
|
121 | | - See [CONTRIBUTING](CONTRIBUTING.md). |
| 102 | + See [CONTRIBUTING](./CONTRIBUTING.md). |
122 | 103 |
|
123 | 104 | ## Open Source @ IBM |
124 | 105 | Find more open source projects on the [IBM Github Page](http://ibm.github.io/) |
125 | 106 |
|
126 | | -## Privacy Notice |
127 | | - |
128 | | -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: |
129 | | - |
130 | | -* Node.js package version |
131 | | -* Node.js repository URL |
132 | | -* Application Name (`application_name`) |
133 | | -* Space ID (`space_id`) |
134 | | -* Application Version (`application_version`) |
135 | | -* Application URIs (`application_uris`) |
136 | | -* Labels of bound services |
137 | | -* Number of instances for each bound service and associated plan information |
138 | | - |
139 | | -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. |
140 | 107 |
|
141 | | -[deploy_track_url]: https://github.com/cloudant-labs/deployment-tracker |
142 | | -[cloud_foundry]: https://github.com/cloudfoundry/cli |
143 | | -[getting_started]: https://www.ibm.com/watson/developercloud/doc/common/index.html |
144 | 108 | [service_url]: https://www.ibm.com/watson/services/speech-to-text/ |
145 | | -[docs]: http://www.ibm.com/watson/developercloud/speech-to-text/ |
146 | | -[sign_up]: https://console.bluemix.net/registration/ |
| 109 | +[docs]: https://www.ibm.com/watson/developercloud/speech-to-text/api/v1/curl.html?curl |
| 110 | +[sign_up]: https://console.bluemix.net/registration/?target=/catalog/services/speech-to-text/ |
| 111 | +[demo_url]: https://speech-to-text-demo.ng.bluemix.net |
0 commit comments