Using the Google Speech API is great. It gives the ability to send a flac file to Google's servers and they'll convert it into the 'best guess' of text.
So far, it's been right on the money. Anyway, I published the code up on GitHub. You can find it here: https://github.com/rogerthomas84/php-speech-to-text
Before you hop in, I have to give credit where credit is due. The hard work was done by Mike Pultz (View his post)
Here's the overview:
PHP Code:
<?php
include 'GoogleSpeechToText.php';
// Your API Key goes here.
$apiKey = '';
$speech = new GoogleSpeechToText($apiKey);
$file = realpath(__DIR__ . '/quick.flac'); // Full path to the file.
$bitRate = 44100; // The bit rate of the file.
$result = $speech->process($file, $bitRate, 'en-US');
var_dump($result);
Running that code (with the flac file from my GitHub project) outputs:
Text Snippet:
array(1) {
  [0]=>
  array(2) {
    ["alternative"]=>
    array(5) {
      [0]=>
      array(2) {
        ["transcript"]=>
        string(44) "the quick brown fox jumped over the lazy dog"
        ["confidence"]=>
        float(0.87096781)
      }
      [1]=>
      array(1) {
        ["transcript"]=>
        string(43) "the quick brown fox jumps over the lazy dog"
      }
      [2]=>
      array(1) {
        ["transcript"]=>
        string(49) "the quick brown fox jumped over the lazy dog cafe"
      }
      [3]=>
      array(1) {
        ["transcript"]=>
        string(49) "the quick brown fox jumped over the lazy dog food"
      }
      [4]=>
      array(1) {
        ["transcript"]=>
        string(47) "the quick brown fox jumped over the lazy dog hi"
      }
    }
    ["final"]=>
    bool(true)
  }
}

asmi shah commented on Dec 30th 2014
Thanks for the code. I exactly followed the steps and finally if I try to run your example code, it says "boolean false".
I created a project on google developers console and enabled the speechAPI and added the key to the php file. The rest is the same then. How could i check if the API is working correctly ?
Something goes wrong here I guess :
$res = curl_multi_getcontent($this->downloadHandle);
as "$this->downloadHandle" echoes "resource(4, curl)" but "$res" echoes a null string ''.
Any help is appreciated! Thanks already!