gillesdemey / node-record-lpcm16

:microphone: Records a 16-bit signed-integer linear pulse modulation code encoded audio file.
ISC License
212 stars 59 forks source link

In local with Google API it's working fine but, deploy on server it's not working. #22

Open higunjan opened 7 years ago

higunjan commented 7 years ago

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.');
}
adeel-raza commented 6 years ago

Facing the exact same problem when deploying on server

Ayushimidha28 commented 4 years ago

I am facing the same error. Did you find any solution?