Skip to content

speechClient.recognize() giving empty array as response? #425

Description

@svsh227

Using google-cloud/speech module my code is running fine and not producing any error, my mp3 file is also ok ( I have tested with multiple .mp3 files ). But is gives the response with empty array every times.

Can anyone please suggest me why is is happening ?

my code is:

// Imports the Google Cloud client library
const Speech = require('@google-cloud/speech');
process.env.GOOGLE_APPLICATION_CREDENTIALS = './speech-368abcdefghi.json'  

// Your Google Cloud Platform project ID
const projectId = 'engaged-talon-123456';

// Instantiates a client
const speechClient = Speech({
  projectId: projectId
});

// The name of the audio file to transcribe
const fileName = './5sec.mp3';

// The audio file's encoding, sample rate in hertz, and BCP-47 language code
const options = {
  encoding: 'LINEAR16',
  sampleRateHertz: 16000,
  languageCode: 'en-US'
};

// Detects speech in the audio file
speechClient.recognize(fileName, options)
  .then((results) => {
    console.log(results);
    // const transcription = results[0];
    // console.log(`Transcription: ${transcription}`);
  })
  .catch((err) => {
    console.error('ERROR:', err);
  });

Result
[" '', { results: [] } ]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚨This issue needs some love.triage meI really want to be triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions