sam*_*ara 5 google-api node.js google-api-nodejs-client electron google-speech-to-text-api
现在,在谷歌语音到文本API中,我正在做我想做的一切,除了当我想要的时候停止现在我已经尝试在API中调用函数stop()、pause(),其中八个不起作用
const record = require('node-record-lpcm16');// Imports the Google Cloud client library
const speech = require('@google-cloud/speech');// Creates a client
const client = new speech.SpeechClient();const encoding = 'LINEAR16';
const sampleRateHertz = 16000;
const languageCode = 'en-US';const request = {
config: {
encoding: encoding,
sampleRateHertz: sampleRateHertz,
languageCode: languageCode,
},
interimResults: false,
};// Create a recognize stream
const recognizeStream = client
.streamingRecognize(request)
.on('error', console.error)
.on('data', data =>
process.stdout.write(
data.results[0] && data.results[0].alternatives[0]
? `Transcription: ${data.results[0].alternatives[0].transcript}\n`
: `\n\nReached transcription time limit, press Ctrl+C\n`
)
);// Start recording and send the microphone input to the Speech API
record
.recorder({
sampleRateHertz: sampleRateHertz,
threshold: 0,
verbose: false,
recordProgram: 'rec', // Try also "arecord" or "sox"
silence: '10.0',
})
.on('error', console.error).stream()
.pipe(recognizeStream);console.log('Listening, press Ctrl+C to stop.');
Run Code Online (Sandbox Code Playgroud)
我现在正在使用这段代码,我尝试像这样调用这个函数record.recorder().stop()
结果是 process.kill("SIGNSTP") 不是符号或无效
然后我尝试过recodr.stop()
找不到这个说的功能
然后尝试将所有内容放入一个类中delete google.TalktoMe()(这是包含所有内容的函数)然后我也认为录音机停止工作但谷歌识别器仍在运行并且发现但当它最终停止沉默时它有时会输出巨大的错误让我应用程序停止工作。有没有人知道答案或解决这个问题,现在已经两天了,我正在文档中抓取,论坛中也没有任何内容,也没有对评论的回复,如果有任何答案,也非常感谢
| 归档时间: |
|
| 查看次数: |
666 次 |
| 最近记录: |