Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
Angular Speech Recognition function is getting called multiple times

I am trying to use Angular-Speech-Recognition in Angular application. Below are my html and component ts code. My speech is correctly getting assigned to this.message. My requirement is, after I complete the speech, I want to call this.getSearchResults(this.message);. But whats happening is for each word in my speech the function call this.getSearchResults(this.message) is happening.

For example, if I speak, "I forgot my password", I expect this.getSearchResults(this.message) to be called once with this.message as "I forgot my password". But whats happening is 4 times the function is getting called, as there are 4 words in my speech (for each word the function getSearchResults is getting triggered). How can I fix it?

 <fa-icon 
 [icon]="faMicrophone" 
 class="microphone-icon" 
 (click)="listenSpeech()">
 </fa-icon> 

listenSpeech() {
    this.speechSrv
      .listen()
      .pipe(resultList)
      .subscribe((list: SpeechRecognitionResultList) => {
        this.message = list.item(0).item(0).transcript;
       this.getSearchResults(this.message);
      });
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It looks like you never unsubscribe so with every click you're making another subscription. Maybe you want to use take(1) to ensure each .subscribe is going to be trigger at most once?

this.speechSrv
  .listen()
  .pipe(resultList) // Don't know what this is so you might put `take(1)` here instead of using two `pipe()` calls
  .pipe(take(1))
  .subscribe((list: SpeechRecognitionResultList) => {
    this.message = list.item(0).item(0).transcript;
   this.getSearchResults(this.message);
  });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!