Skip to content

Instantly share code, notes, and snippets.

@itskenny0
itskenny0 / witai_speech.php
Created August 19, 2016 08:10
wit.ai speech recognition in PHP
<?php
/* wit.ai speech recognition in PHP */
$request = curl_init('https://api.wit.ai/speech');
$headers[] = 'Authorization: Bearer YOURAPIKEY';
$headers[] = 'Content-Type: audio/wav';
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($request, CURLOPT_POSTFIELDS, file_get_contents("soundfile.wav"));
curl_setopt($request, CURLOPT_HTTPHEADER, $headers);