ASR for multiple languages in angular demo
See original GitHub issuehello
Thank you for sharing your knowledge
I want to use multiple languages in the Angular program demo.
For this purpose, I changed the following code in app.component.ts :
import { Component } from '@angular/core';
import { ElementRef, ViewChild} from '@angular/core'
import { DictateService } from "./dictate-service";
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [DictateService]
})
export class AppComponent {
@ViewChild('results') private results: ElementRef;
buttonText = 'شروع ضبط';
buttonText_russian = 'شروع ضبط';
textDataBase = '';
textData = '';
persian_server = "ws://localhost:2700";
russian_server = "ws://localhost:2701";
constructor(private dictateService: DictateService) {
}
switchSpeechRecognition() {
if ( !this.dictateService.isInitialized() || this.persian_server === null ) {
this.persian_server = "ws://localhost:2700";
this.russian_server = null ;
this.dictateService.cancel();
this.dictateService.init({
server: this.persian_server,
onResults: (hyp) => {
console.log(hyp);
this.textDataBase = this.textDataBase + hyp + '\n';
this.textData = this.textDataBase;
this.results.nativeElement.scrollTop = this.results.nativeElement.scrollHeight;
},
onPartialResults: (hyp) => {
console.log(hyp);
this.textData = this.textDataBase + hyp;
},
onError: (code, data) => {
console.log(code, data);
},
onEvent: (code, data) => {
console.log(code, data);
}
});
this.buttonText_russian = 'شروع ضبط';
document.getElementById("listening_gif").style.display = "none";
this.buttonText = 'پایان ضبط';
document.getElementById("listening_gif").style.display = "inline";
} else if (this.dictateService.isRunning()) {
this.dictateService.resume();
this.buttonText = 'پایان ضبط';
document.getElementById("listening_gif").style.display = "inline";
} else {
this.dictateService.pause();
this.buttonText = 'شروع ضبط';
document.getElementById("listening_gif").style.display = "none";
}
}
cleararea() {
var cl = document.getElementById("textarea") ;
console.log(cl);
cl.value = "";
this.textDataBase = '';
}
switchSpeechRecognition_russian() {
if ( !this.dictateService.isInitialized() || this.russian_server === null ) {
this.persian_server = null;
this.russian_server = "ws://localhost:2701" ;
this.dictateService.cancel();
this.buttonText = 'شروع ضبط';
document.getElementById("listening_gif").style.display = "none";
this.dictateService.init({
server: this.russian_server,
onResults: (hyp) => {
console.log(hyp);
this.textDataBase = this.textDataBase + hyp + '\n';
this.textData = this.textDataBase;
this.results.nativeElement.scrollTop = this.results.nativeElement.scrollHeight;
},
onPartialResults: (hyp) => {
console.log(hyp);
this.textData = this.textDataBase + hyp;
},
onError: (code, data) => {
console.log(code, data);
},
onEvent: (code, data) => {
console.log(code, data);
}
});
this.buttonText_russian = 'پایان ضبط';
document.getElementById("listening_gif").style.display = "inline";
} else if (this.dictateService.isRunning()) {
this.dictateService.resume();
this.buttonText_russian = 'پایان ضبط';
document.getElementById("listening_gif").style.display = "inline";
} else {
this.dictateService.pause();
this.buttonText_russian = 'شروع ضبط';
document.getElementById("listening_gif").style.display = "none";
}
}
}
The correct results are displayed for the first time, but when I select another language, the results are no longer correct.
I think the error is in following code , but I do not know how to correct it
node.onaudioprocess = (e) => {
if (this.paused) return;
// console.log("00000000000000000000000000000000000000000000000");
// console.log(e.inputBuffer.getChannelData(0));
// console.log("00000000000000000000000000000000000000000000000");
this.worker.postMessage({
command: 'record',
buffer: [
e.inputBuffer.getChannelData(0)
]
});
};
please help.
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Multiple Language Support in Angular Application using i18n
In this article, we will discuss about “how our angular application can support multiple languages”. But wait do our application really need ...
Read more >Speech-to-Text supported languages - Google Cloud
Name BCP‑47 Model Boost Profanity filter
Afrikaans (South Africa) af‑ZA Command and search ✓ ✓
Afrikaans (South Africa) af‑ZA Default ✓ ✓
Albanian (Albania) sq‑AL Command...
Read more >Speech to Text – Audio to Text Translation | Microsoft Azure
Convert spoken audio to text within your apps for more accessible converted audio to ... transcribe audio to text in more than 100...
Read more >Porcupine Wake Word | Angular - Picovoice Docs
Picovoice Account and AccessKey; Node.js 14+; Angular 13+; npm ... In order to use Porcupine with other languages, you need to use the...
Read more >Angular: creating a multilanguage application - YouTube
Angular creating a multilanguage application with json files for every corresponding language. In this tutorial I will explain to you how to ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Again, the problem is in your code, our code doesn’t have this feature at all
Most likely you subscribe to audio stream twice (like you call startUserMedia several times) so you get each audio chunk many times. You shouldn’t do that when you switch languages.
It works very good when i call startUserMedia once… thank you very much