Skip to content

Commit 88988a9

Browse files
Merge pull request #111 from w0o/master
Fix for #110 : IAM parameter not being used server and server fails starting
2 parents 3d6c69d + 347e17f commit 88988a9

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ var recognizeMic = require('watson-speech/speech-to-text/recognize-microphone');
3939

4040
This SDK _CAN_ be used in the browser with services that use IAM for authentication. This does require a server-side component - an endpoint used to retrieve the token. An example can be found [here](https://github.com/watson-developer-cloud/speech-javascript-sdk/blob/master/examples/server.js#L92).
4141

42+
In a local environment you should set only the TEXT_TO_SPEECH_IAM_APIKEY and SPEECH_TO_TEXT_IAM_APIKEY in your .env file, see example file [here](https://github.com/watson-developer-cloud/speech-javascript-sdk/blob/master/examples/.env.example).
43+
4244
Once that is set up, the token can be used in your SDK request with the parameter `access_token`. See [this example](https://github.com/watson-developer-cloud/speech-javascript-sdk/blob/master/examples/static/microphone-streaming.html#L36).
4345

4446
## Changes

examples/.env.example

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Replace this if you are using a region specific service
2+
SPEECH_TO_TEXT_URL=https://stream.watsonplatform.net/speech-to-text/api
3+
4+
# If your using IAM API keys use this and do not input credentials:
5+
SPEECH_TO_TEXT_IAM_APIKEY=<Your API key>
6+
7+
# If your Speech to Text credentials contain username and password use the following:
8+
SPEECH_TO_TEXT_USERNAME=
9+
SPEECH_TO_TEXT_PASSWORD=
10+
11+
# Replace this if you are using a region specific service
12+
TEXT_TO_SPEECH_URL=https://stream.watsonplatform.net/text-to-speech/api
13+
14+
# If your using IAM API keys use this and do not input credentials:
15+
TEXT_TO_SPEECH_IAM_APIKEY=<Your API key>
16+
17+
# If your Text to Speech credentials contain username and password use the following:
18+
TEXT_TO_SPEECH_USERNAME=
19+
TEXT_TO_SPEECH_PASSWORD=
20+

examples/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ var sttAuthService = new AuthorizationV1(
8888
Object.assign(
8989
{
9090
username: process.env.SPEECH_TO_TEXT_USERNAME, // or hard-code credentials here
91-
password: process.env.SPEECH_TO_TEXT_PASSWORD
92-
// iam_apikey: process.env.SPEECH_TO_TEXT_IAM_APIKEY // if using an RC service
91+
password: process.env.SPEECH_TO_TEXT_PASSWORD,
92+
iam_apikey: process.env.SPEECH_TO_TEXT_IAM_APIKEY // if using an RC service
9393
},
9494
vcapServices.getCredentials('speech_to_text') // pulls credentials from environment in bluemix, otherwise returns {}
9595
)

0 commit comments

Comments
 (0)