Advertisement
Guest User

Untitled

a guest
Jun 14th, 2012
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?php
  2.     $filename = "audio.flac";
  3.     $audio = file_get_contents($filename);
  4.     $data = array(
  5.         "Content_Type"  =>  "audio/x-flac; rate=16000",
  6.         "Content"       =>  $audio,
  7.     );
  8.     $ch = curl_init();
  9.     curl_setopt($ch, CURLOPT_URL, 'https://www.google.com/speech-api/v1/recognize?xjerr=1&client=chromium&lang=en-US');
  10.     curl_setopt( $ch, CURLOPT_HTTPHEADER, array("Content-Type: audio/x-flac; rate=16000"));
  11.     curl_setopt($ch, CURLOPT_POST, true);
  12.     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  13.     ob_start();
  14.     curl_exec($ch);
  15.     curl_close($ch);
  16.     $contents = ob_get_contents();
  17.     ob_end_clean();
  18.     print_e($contents);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement