How to use the Web Speech API in NodeJS
Asked Answered
C

3

10

I am wondering if it is possible to run the Web Speech API in node.js? Since node is Javascript based, I was assuming it could be used, but I can't find a way to use it natively in node. Would there be a way to "include" this Web Speech Library in a node.js script to use it?

Thank you

Cousins answered 2/2, 2017 at 16:10 Comment(2)
what are you trying to accomplish? Who would be speaking to the server? Or are you considering a recorded wav of some sort?Litta
there is headless chrome nowAnkledeep
X
7

While you can't use the WebSpeechAPI in Node (as it is a built in browser capability), you can use Google Cloud Speech or one of the many other cloud recognizers that have Node SDKs.

If you're looking for a super lightweight implementation that handles all of the audio encoding and supports offline hotword detection I would recommend Sonus.

Disclaimer: this is my project

Xerophyte answered 2/2, 2017 at 22:51 Comment(0)
R
1

You can try WSNR npm module, but it requires running a chrome browser.

Rip answered 15/3, 2020 at 10:18 Comment(0)
L
-3

Demo.JS

angular.module('PubNubAngularApp', ["pubnub.angular.service"])
.controller('MySpeechCtrl', function($rootScope, $scope, Pubnub) {
  $scope.theText = "Don't just stand there, say something!";
  $scope.dictateIt = function () {
      $scope.theText = "";
      var recognition = new webkitSpeechRecognition();
      recognition.onresult = function (event) {
        $scope.$apply(function() {
          for (var i = event.resultIndex; i < event.results.length; i++) {
            if (event.results[i].isFinal) {
              $scope.theText  += event.results[i][0].transcript;
            }
          }
        });
      };
      recognition.start();
  };
});

Link to codepen.io demo

Here is the complete package for you.

Landers answered 9/3, 2018 at 10:5 Comment(1)
This doesn't answer the question as it will only work in the browser, whereas the OP was asking how to use the Web Speech API in node.js.Embrey

© 2022 - 2024 — McMap. All rights reserved.