ceuk / speech-recognition-aws-polyfill

Polyfill for the SpeechRecognition browser API using AWS Transcribe as a fallback
Other
10 stars 8 forks source link

A solid DEMO project Example. #7

Open soltrinox opened 2 years ago

soltrinox commented 2 years ago

Would love to see a DEMO repo companion example for this.

Does the streaming allow for pause MICROPHONE event/method ?

ceuk commented 2 years ago

Hey, yeah agree a demo would be really valuable - I'll see if I can put one together this/next week.

If I'm understanding your second question correctly you're asking "is there a way to suspend mic capture and then resume it at a later point"?

You could expand on the below perhaps?

const recognition = new Recognitition({
  IdentityPoolId: "12345",
  region: "abc"
});

recognition.continuous = true;

recognition.addEventListener("error", console.error);
recognition.addEventListener("end", () => console.log("end"));

recognition.addEventListener("result", function (event) {
  const { transcript } = event.results[0][0];
  console.log(transcript);
  // do something with the transcript - e.g. write it to the page
});

// start listening
recognition.start();

// "pause" the microphone (use recognition.start() to unpause)
recognition.stop();