Hello their I used following code and integrate with Google API to convert speech to text.
In local demo is working fine and call instance and display text. when I load on server than it's called only once than stop execution.
When I speak in local than .on('data', function(data){ calls many time after that auto killed.
On server it's call only once.
/ [START speech_streaming_mic_recognize]
const record = require('node-record-lpcm16');
methods.streamingMicRecognize = function(callback){
// Instantiates a client
const speech = Speech({
projectId: projectId
});
const options = {
config: {
// Configure these settings based on the audio you're transcribing
encoding: 'LINEAR16',
languageCode: 'en-IN',
sampleRate: 16000
}
};
// Create a recognize stream
const recognizeStream = speech.createRecognizeStream(options)
.on('error', function(error){
console.error
})
.on('data', function(data){
process.stdout.write(data.results);
});
// Start recording and send the microphone input to the Speech API
record.start({ sampleRate: 16000 }).pipe(recognizeStream);
console.log('Listening, press Ctrl+C to stop.');
}
Hello their I used following code and integrate with Google API to convert speech to text. In local demo is working fine and call instance and display text. when I load on server than it's called only once than stop execution.
When I speak in local than
.on('data', function(data){
calls many time after that auto killed. On server it's call only once.