admin管理员组

文章数量:1290938

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

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

Share Improve this question asked Feb 2, 2017 at 16:10 BobBob 3635 silver badges14 bronze badges 2
  • what are you trying to acplish? Who would be speaking to the server? Or are you considering a recorded wav of some sort? – akaphenom Commented Feb 2, 2017 at 16:16
  • there is headless chrome now – Muhammad Umer Commented Dec 29, 2017 at 9:31
Add a ment  | 

3 Answers 3

Reset to default 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 remend Sonus.

Disclaimer: this is my project

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

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 plete package for you.

本文标签: javascriptHow to use the Web Speech API in NodeJSStack Overflow