如何在 node.js 服务器上使用 AnnYang 语音识别?
Posted
技术标签:
【中文标题】如何在 node.js 服务器上使用 AnnYang 语音识别?【英文标题】:How to use AnnYang speech reconigition on the node.js server? 【发布时间】:2015-05-29 12:43:38 【问题描述】:更新日志:
ws@0.5.0 install /Users/matthew.harwood/workspace/akqa/insights/tts/node-pocketsphinx/node_modules/socket.io/node_modules/engine.io/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
> ws@0.4.31 install /Users/matthew.harwood/workspace/akqa/insights/tts/node-pocketsphinx/node_modules/socket.io/node_modules/socket.io-client/node_modules/engine.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
> pocketsphinx@1.0.1 install /Users/matthew.harwood/workspace/akqa/insights/tts/node-pocketsphinx
> node-gyp rebuild
Package pocketsphinx was not found in the pkg-config search path.
Perhaps you should add the directory containing `pocketsphinx.pc'
to the PKG_CONFIG_PATH environment variable
No package 'pocketsphinx' found
Package sphinxbase was not found in the pkg-config search path.
Perhaps you should add the directory containing `sphinxbase.pc'
to the PKG_CONFIG_PATH environment variable
No package 'sphinxbase' found
gyp: Call to 'pkg-config --cflags pocketsphinx sphinxbase' returned exit status 1. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:820:12)
gyp ERR! System Darwin 13.2.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/matthew.harwood/workspace/akqa/insights/tts/node-pocketsphinx
gyp ERR! node -v v0.10.35
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok
npm ERR! Darwin 13.2.0
npm ERR! argv "node" "/usr/local/bin/npm" "install"
npm ERR! node v0.10.35
npm ERR! npm v2.1.18
npm ERR! code ELIFECYCLE
npm ERR! pocketsphinx@1.0.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pocketsphinx@1.0.1 install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the pocketsphinx package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls pocketsphinx
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/matthew.harwood/workspace/akqa/insights/tts/node-pocketsphinx/npm-debug.log
我有一个带有节点安装的树莓派。我想要一种运行语音识别的方法;但是我希望web speech api 在没有打开浏览器窗口的情况下运行。
问题:所以我找到了annyang-node 的node mod 版本,但似乎无法让它运行?
问题:如何在不打开浏览器的情况下使用原版网络语音 api 或 annyang 从节点,例如从node index.js
运行这可能吗?
index.js
var Annyang = require('annyang');
var http = require('http');
http.createServer(function (req, res)
res.writeHead(200, 'Content-Type': 'text/plain');
res.end('Hello World\n');
).listen(1337, '127.0.0.1');
console.log('Server running at http://127.0.0.1:1337/');
var annyang = new Annyang();
// Let's define a command.
var commands =
'show tps report': function()
// do something
;
// Initialize our commands with annyang
annyang.init(commands);
// Trigger a command
annyang.trigger('show tps report');
【问题讨论】:
【参考方案1】:Annyang 不能在 node 上运行,它需要一个浏览器,因为浏览器实现了网络语音 API。
对于 raspberry PI 上的固定命令集,最好尝试 node-pocketsphinx
http://github.com/cmusphinx/node-pocketsphinx
【讨论】:
错误:找不到模块 './build/Release/PocketSphinx.node' 有什么想法吗? 不用着急,请提供更多关于您看到的错误的确切原因的信息,我相信它很容易修复。 感谢您的彩色字体的精彩视频。对于未来,软件开发人员更喜欢文本日志,而不是屏幕截图或视频。永远不要尝试在 docx 文件中插入视频或屏幕截图并分享。日志更有帮助,因为您可以阅读它们,而不是尝试从视频中逐帧提取。在您的日志中,您可能会看到错误“Npm install failed with “cannot run in wd”,下面的答案 ***.com/questions/18136746/… 对此进行了介绍 你需要先安装sphinxbase和pocketsphinx。您还需要将 pkg-config 路径设置为指向 /usr/local/lib/pkg-config。见wolfpaulus.com/jounal/embedded/raspberrypi2-sr 太棒了!你应该把它放到你在 github 上的 README.md 中。期待使用您的回购!谢谢!以上是关于如何在 node.js 服务器上使用 AnnYang 语音识别?的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 XAMPP 或 node.js 使 AJAX 在本地服务器上工作
如何使用 Amazon Elastic Beanstalk 在端口 80 上安全地运行 Node.js 服务器?