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

Bob
  • 353
  • 5
  • 14

3 Answers3

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

evancohen
  • 677
  • 1
  • 5
  • 9
1

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

DedaDev
  • 4,441
  • 2
  • 21
  • 28
-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.

SaschaM78
  • 4,376
  • 4
  • 33
  • 42
Adnan Khan
  • 70
  • 2
  • 9
  • 2
    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. – Hayko Koryun Jul 12 '18 at 09:20