我使用下面的代码片段进行谷歌语音到文本识别,
var speech = require('google-speech-api');
var opts = {
file: 'speech.mp3',
key: '<Google API Key>'
};
speech(opts, function (err, results) {
console.log(results);
// [{result: [{alternative: [{transcript: '...'}]}]}]
});
然后我试着做
“npm 安装 google-speech-api”
从命令提示符。它给出错误。然后,我做了
“npm 安装 googleapis”
它成功了。我从命令提示符“node myspeech.js”执行了 Node.js 脚本......它抛出错误,
module.js:341
throw err;
^
Error: Cannot find module 'google-speech-api'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\myspeechtest.js:1:76)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)