Skip to content

Commit

Permalink
fix: Use readable-stream to enable angular users (#118)
Browse files Browse the repository at this point in the history
Fixes #103 and could also solve the problem with #83.

I made a mistake with the rebase so we should squash this with a  `fix: Add support for Angular` commit message

Co-authored-by: Michael Chou <mingzhi22@gmail.com>
Co-authored-by: Dustin Popp <dpopp07@gmail.com>
Co-authored-by: null <wolf.bocanett@ibm.com>
Co-authored-by: Darío Hereñú <magallania@gmail.com>
Co-authored-by: Gurvinder Singh <sinny777@gmail.com>
  • Loading branch information
6 people authored Apr 5, 2019
1 parent 72b0b70 commit 462a475
Show file tree
Hide file tree
Showing 11 changed files with 637 additions and 209 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ In a local environment you should set only the `TEXT_TO_SPEECH_IAM_APIKEY` and `

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).

## Using with Angular

Make sure `polyfills.ts` has following entries:

```js
(window as any).global = window;
(window as any).process = require('process/browser');
import 'zone.js/dist/zone'; // Included with Angular CLI.
global.Buffer = global.Buffer || require('buffer').Buffer;
```

## Changes

See [CHANGELOG.md](CHANGELOG.md) for a complete list of changes.
Expand Down
806 changes: 610 additions & 196 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
}
],
"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@babel/cli": "^7.4.3",
"@babel/core": "^7.4.3",
"@babel/preset-env": "^7.4.3",
"babel-loader": "^8.0.5",
"babelify": "^10.0.0",
"browserify": "^16.2.3",
Expand Down Expand Up @@ -68,18 +68,20 @@
"webpack-cli": "^3.3.0"
},
"dependencies": {
"@babel/polyfill": "^7.4.0",
"@babel/polyfill": "^7.4.3",
"buffer-from": "^1.1.1",
"clone": "^2.1.2",
"core-js": "^3.0.0",
"defaults": "^1.0.3",
"get-user-media-promise": "^1.1.4",
"lodash.pullallwith": "^4.7.0",
"microphone-stream": "^4.1.3",
"microphone-stream": "^5.0.1",
"nodeify-fetch": "^1.0.1",
"object.assign": "^4.1.0",
"object.pick": "^1.3.0",
"path": "^0.12.7",
"readable-blob-stream": "^1.1.0",
"readable-stream": "^3.3.0",
"watson-developer-cloud": "^3.18.3",
"websocket": "^1.0.28",
"whatwg-fetch": "^2.0.4"
Expand Down
2 changes: 1 addition & 1 deletion speech-to-text/format-stream.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var Transform = require('stream').Transform;
var { Transform } = require('readable-stream');
var util = require('util');
var clone = require('clone');
var defaults = require('defaults');
Expand Down
2 changes: 1 addition & 1 deletion speech-to-text/recognize-microphone.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var L16 = require('./webaudio-l16-stream.js');
var FormatStream = require('./format-stream.js');
var assign = require('object.assign/polyfill')();
var WritableElementStream = require('./writable-element-stream');
var Writable = require('stream').Writable;
var { Writable } = require('readable-stream');
var ResultStream = require('./result-stream');
var SpeakerStream = require('./speaker-stream');

Expand Down
2 changes: 1 addition & 1 deletion speech-to-text/recognize-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

'use strict';

var Duplex = require('stream').Duplex;
var { Duplex } = require('readable-stream');
var util = require('util');
var pick = require('object.pick');
var W3CWebSocket = require('websocket').w3cwebsocket;
Expand Down
2 changes: 1 addition & 1 deletion speech-to-text/result-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

'use strict';

var Transform = require('stream').Transform;
var { Transform } = require('readable-stream');
var util = require('util');
var clone = require('clone');

Expand Down
2 changes: 1 addition & 1 deletion speech-to-text/speaker-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

'use strict';

var Transform = require('stream').Transform;
var { Transform } = require('readable-stream');
var util = require('util');
var pullAllWith = require('lodash.pullallwith');
var noTimestamps = require('./no-timestamps');
Expand Down
2 changes: 1 addition & 1 deletion speech-to-text/timing-stream.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var Transform = require('stream').Transform;
var { Transform } = require('readable-stream');
var util = require('util');
var defaults = require('defaults');
var noTimestamps = require('./no-timestamps');
Expand Down
3 changes: 2 additions & 1 deletion speech-to-text/webaudio-l16-stream.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';
var Transform = require('stream').Transform;

var { Transform } = require('readable-stream');
var util = require('util');
var defaults = require('defaults');
// some versions of the buffer browser lib don't support Buffer.from (such as the one included by the current version of express-browserify)
Expand Down
2 changes: 1 addition & 1 deletion speech-to-text/writable-element-stream.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

var Writable = require('stream').Writable;
var { Writable } = require('readable-stream');
var util = require('util');
var defaults = require('defaults');

Expand Down

0 comments on commit 462a475

Please sign in to comment.