0

so I have an iframe video in my html code

<iframe width="420" height="345" id="my video" src="testvid.mp4">

In my javascript code I am using the Webkitspeech api to detect English in real-time. Here is the code logic. https://developers.google.com/web/updates/2013/01/Voice-Driven-Web-Apps-Introduction-to-the-Web-Speech-API

  var recognition = new webkitSpeechRecognition();
      recognition.continuous = true;
      recognition.interimResults = true;

      recognition.onstart = function() { ... }

      recognition.onresult = function(event) {
var interim_transcript = '';

    for (var i = event.resultIndex; i < event.results.length; ++i) {
      if (event.results[i].isFinal) {
        final_transcript += event.results[i][0].transcript;
      } else {
        interim_transcript += event.results[i][0].transcript;
      }
    }
    final_transcript = capitalize(final_transcript);
    final_span.innerHTML = linebreak(final_transcript);
    interim_span.innerHTML = linebreak(interim_transcript);
  };
}
      recognition.onerror = function(event) { ... }
      recognition.onend = function() { ... }

The PROBLEM is that this recognition API is great for detecting all sounds being emitted to the browser such as the user's mic but..... What I WANT is to have this "recognition" function ONLY detect audio from the iframe video. Is it possible to do this with the Webkitspeech api? Or is there another api I need to use? A Code example would be greatly appreciated. Thank you all!

Mystery Man
  • 535
  • 2
  • 7
  • 20
  • Personal use only or should it work for any user? – Kaiido Nov 19 '19 at 06:53
  • It should work for anyone who views the website. When they play the video they hear it but the recognition api only takes the speech to text from the video not any other noise. – Mystery Man Nov 19 '19 at 12:35
  • Then I fear that's unfortunately not possible... There is no way from Web API to set the sink from where the SpeechRecognition will be made. If it had been for personal use only, yo could have made a setup at the os level so that your video routes to a virtual device that would also be used as default audio input (and hence by the web-speech API). But that's not a viable solution for a site facing the web... Now things may have changed since last time I checked, but I doubt it. – Kaiido Nov 19 '19 at 13:31
  • How to get speech to text from the video? Or is there a way we can mute user mic? – Mystery Man Nov 19 '19 at 14:28

0 Answers0