0

I am developing a website that will have an audio to text page, i am trying to use the API from Google but it seems to load indefinitly and giving me a timeout, on the Google console it show me that request has been made so i guess it come from my rendering (I am developing on Symfony)

Here's my function

public function transcribeAction($audioFile = 'C:\Users\Poste3\Downloads\rec.flac', $languageCode = 'fr-FR', $options = ['sampleRateHertz' => 16000, 'speechContexts' => ['phrases' => ['The Google Cloud Platform', 'Speech API']]])
{

    // Create the speech client
    $speech = new SpeechClient([
        'keyFilePath' => 'C:\Users\Poste3\Downloads\Speech-74da45e82b8e.json',
        'languageCode' => $languageCode,
    ]);

    // Make the API call
    $results = $speech->recognize(
        fopen($audioFile, 'r'),
        $options
    );

    // Print the results
    foreach ($results as $result) {
        $alternative = $result->alternatives()[0];
        printf('Transcript: %s' . PHP_EOL, $alternative['transcript']);
        printf('Confidence: %s' . PHP_EOL, $alternative['confidence']);
    }

    return $this->render('OCPlatformBundle:Advert:speech.html.twig');
}

And here's the call to the function

{{ render(controller('OCPlatformBundle:Advert:transcribe')) }}
Eliatrom
  • 1
  • 5

1 Answers1

0

First of all you should dump the response you are getting from Speech API.

Possible problems here:

  • Key is not correctly configured, and has no permissions to make this operation
  • Your file is more than 1 minute long, in this case google speech requires you to first upload .flac file to Google Cloud and use longrunningrecognize
wIRELESS
  • 196
  • 3
  • 3