Menu

#328 Error code 2 with Google Speech API on EC2 instance

closed-invalid
nobody
None
5
2021-01-07
2019-09-06
ankuj arora
No

Hello,

I'm facing a "sox has exited with error code 2" whilst running sox as part of a Google Speech API request on an AWS Linux instance. I installed sox using the 'yum install sox' command. Any idea what the problem might be? Thanks a lot for your help!

Discussion

  • ayka

    ayka - 2020-05-28

    Hello,
    I am facing the same issue did you solve it?

     
    • Mans Rullgard

      Mans Rullgard - 2020-05-28

      It might help if you told us what you are doing, preferably including a command line (and test file if necessary) that reproduces the problem.

       
      • ayka

        ayka - 2020-05-29

        I have created a web application using google speech to text api. My web application is working fine on local machine but not on google cloud platorm.

        In the following code node-record-lpcm16 module requires you to install SoX and it must be available in your $PATH.
        To make it work on google cloud platform that i have created a container in which i have installed sox and runnning node comand to initialize the program. ** I am receiving an error sox exited with error code 2.**

        const recorder = 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 request = {
        config: {
        encoding: encoding,
        sampleRateHertz: sampleRateHertz,
        languageCode: languageCode,
        },
        interimResults: false, // If you want interim results, set this to true
        };
        
        // 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.
        // Ensure SoX is installed, see https://www.npmjs.com/package/node-record-lpcm16#dependencies
        recorder
        .record({
        sampleRateHertz: sampleRateHertz,
        threshold: 0,
        // Other options, see https://www.npmjs.com/package/node-record-lpcm16#options
        verbose: false,
        recordProgram: 'rec', // Try also "arecord" or "sox"
        silence: '10.0',
        })
        .stream()
        .on('error', console.error)
        .pipe(recognizeStream);
        
        console.log('Listening, press Ctrl+C to stop.');
        
         

        Last edit: ayka 2020-05-29
        • Mans Rullgard

          Mans Rullgard - 2020-05-29

          I haven't the faintest clue what any of that is supposed to do. If you want help here, you'll need to find the exact sox command that is failing.

          Now I'm going to venture a guess that perhaps the Google cloud server doesn't have a microphone.

           
  • Mans Rullgard

    Mans Rullgard - 2020-08-03
    • status: open --> closed-invalid
     
  • Mans Rullgard

    Mans Rullgard - 2020-08-03

    This is almost certainly not a sox problem. Closing.

     
  • Myat Noe

    Myat Noe - 2021-01-07

    "sox has exited with error code 2" while running sox as part of a Google Speech API request on an Heroku Cloud. Any idea what the problem might be? Thanks a lot for your help

     

Log in to post a comment.

MongoDB Logo MongoDB