Node.JS:config Speech\u上下文中的谷歌云语音
我正在使用Google语音API的Node.JS变体 在我敢传入一个字符串数组Node.JS:config Speech\u上下文中的谷歌云语音,node.js,google-cloud-speech,Node.js,Google Cloud Speech,我正在使用Google语音API的Node.JS变体 在我敢传入一个字符串数组speech\u contextparameter之前,一切都很好。当我尝试以下每种方式时,流会中断,但不会发出错误。因此,我无法诊断 我正在传递一个字符串数组[“一”、“二”、“三”],遵守,所以我相信。我的原始配置如下所示: const cf = { config: { encoding: 'LINEAR16', sampleRate: 48000 } } 我试过c
speech\u context
parameter之前,一切都很好。当我尝试以下每种方式时,流会中断,但不会发出错误。因此,我无法诊断
我正在传递一个字符串数组[“一”、“二”、“三”]
,遵守,所以我相信。我的原始配置如下所示:
const cf = {
config: {
encoding: 'LINEAR16',
sampleRate: 48000
}
}
我试过cf.config.speech\u context=ARRAY
,cf.config.speech\u context.phrases=ARRAY
,cf.speech\u context=ARRAY
,以及cf.speech\u context.phrases=ARRAY
同样,我没有收到错误消息,也没有得到结果。我什么也得不到。原始配置本身工作
这是一个基本流:
recognizeStream = speech.createRecognizeStream(cf)
.on('error', console.error)
.on('data', console.log)
想法?任何帮助都将不胜感激
const request = {
config: {
encoding: encoding,
sampleRate: sampleRate,
languageCode:'en-IN-x-longform',
}
};
// Stream the audio to the Google Cloud Speech API
const recognizeStream = speech.createRecognizeStream(request)
.on('error', (error) => {
console.error;
})
.on('data', (data) => {
console.log('Data received: %j', data);
if('results' in data)
console.log(chalk.bgYellow( data.results ));
logger.log(JSON.stringify(data));
});
// Stream an audio file from disk to the Speech API, e.g. "./resources/audio.raw"
filename = "./resources/audio.raw";
fs.createReadStream(filename).pipe(recognizeStream);
//This is working for me
//I think you are missing the pipe part in , so you can do
recognizeStream = speech.createRecognizeStream(cf)
.on('error', console.error)
.on('data', console.log)
filename = "./resources/audio.raw";
fs.createReadStream(filename).pipe(recognizeStream);
`