Skip to content

Umamad/google-voice-recognition

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Google Voice Recognition

  • Using google api's to transform voice to text.

Description

SpeechRecognition

  • Method of window object we going to make it standard with lines below
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition;
  • Make an instance
const recognition = new SpeechRecognition();
  • Set language

Default on 'en-US'

recognition.lang = "fa-IR";
  • This line of code couses to fetch result one by one at moment
recognition.interimResults = true;
  • Start by calling start method
recognition.start();

Options

  • We connect all results by join() method then like below
let transcript = Array.from(event.results)
        .map((el) => {
          return el[0];
        })
        .map((el) => {
          return el.transcript;
        })
        .join(" ");
  • Then we have string so we can explore it with includes() method, I mean
    if (result.includes("Order")) {
        // Remove Order Text From Screen
        result = '';
        // What You Want To Do On This Order
        RelatedOrderMethod();
    }
  • Example :
    if (transcript.includes("jump next line")) {
        // Remove Order Text From Screen
        transcript = '';
        // Action
        p = document.createElement("p");
        textPlace.appendChild(p);
    }

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published