-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use in angular 6 #103
Comments
Hi @kulandairaj |
Hi, and imported like this in my app.component.ts file var recognizeMic = require('watson-speech/speech-to-text/recognize-microphone'); I get below error when i compile the application. Error: ERROR in ./node_modules/watson-speech/speech-to-text/content-type.js |
Please provide a set of reproducible steps. |
install angular cli lastest ng version:
modify import { Component, OnInit } from '@angular/core';
import recognizeMicrophone from 'watson-speech/speech-to-text/recognize-microphone';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
ngOnInit(): void {
let resultStream = recognizeMicrophone.recognizeMicrophone();
//throw new Error("Method not implemented.");
}
title = 'rep-step-project';
} run:
|
Hi, Everybody npm i path stream - does not resolve the issue (appears the new in the browser "buffer is not defined") import { recognizeMicrophone} from 'watson-speech/speech-to-text/recognize-microphone'; startStream(): void {
this.isStreaming = true;
this.stream = recognizeMicrophone(this.setOptions(this.token));
this.ngZone.runOutsideAngular(() => {
this.stream.on('data', data => {
this.ngZone.run(() => {
this.text = data.alternatives[0].transcript;
});
});
});
}
|
I just published a new version where we use webpack and babel to bundle the javascript. Can you please check if the latest changes fixed your issue @yLeushun? |
Hi German, Thank you for your attention Unfortunately, it did not help, it seems that since Angular6 something changed in webpack setup and now it is not possible to use Angular-CLI to build a app... Here the full {
"name": "ap",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"core-js": "^2.5.4",
"path": "^0.12.7",
"rxjs": "~6.3.3",
"rxjs-compat": "^6.4.0",
"stream": "0.0.2",
"tslib": "^1.9.0",
"watson-developer-cloud": "^3.18.4",
"watson-speech": "0.35.9",
"websocket-stream": "^5.3.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular/cli": "~7.3.6",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^8.10.45",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
}
} Error in the browser when start app(ng serve -o)
|
I'm also facing the same issue and am using Angular 6. I've installed stream and path modules and then it compiled successfully but running on browser throws error "Buffer is not defined". Is there any other way of implementing Watson STT with Angular 6 (backend is Nodejs) ? |
Hey everyone, I believe this is due to a decision made in Angular 6 to stop polyfilling Node modules. This decision is explained in this comment on an issue in their repo. This broke a lot of users and seems to be affecting us as well, we just haven't yet found a workaround |
I finally got this to working with Angular 6 after making following changes:
Update all files to use readable-stream instead of stream inside var {
Readable,
Writable,
Transform,
Duplex,
pipeline,
finished
} = require('readable-stream'); Make sure
That's it. |
@sinny777 do you mind writing a PR to this project? Maybe that could help fix the issue for the other people here |
@germanattanasio I've just submitted a PR to this project and more than anyone else I also need this fix so that it works with Angular6 |
@sinny777, Your solution is excellent!!! It works on Angular7 |
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 <[email protected]> Co-authored-by: Dustin Popp <[email protected]> Co-authored-by: null <[email protected]> Co-authored-by: Darío Hereñú <[email protected]> Co-authored-by: Gurvinder Singh <[email protected]>
🎉 This issue has been resolved in version 0.35.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I am getting error
import { Component, OnInit } from '@angular/core'; @component({ constructor() { } ngOnInit() { onListenClick() { fetch('https://876409.ngrok.io/api/speech-to-text/token')
// document.querySelector('#stop').onclick = stream.stop.bind(stream);
}
|
I'm running into the same issue
|
Remember, an issue is not the place to ask questions. You can use Stack Overflow for that, or you may want to start a discussion on the dW Answers.
When reporting a bug, please be sure to include the following:
The text was updated successfully, but these errors were encountered: