Skip to content

Instantly share code, notes, and snippets.

@cstrouse
Last active January 9, 2020 04:05
Show Gist options
  • Save cstrouse/e515b897048228c28a85b07122824692 to your computer and use it in GitHub Desktop.
Save cstrouse/e515b897048228c28a85b07122824692 to your computer and use it in GitHub Desktop.
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/transcript', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'audio_url' => 'https://app.assemblyai.com/static/media/phone_demo_clip_1.wav',
'word_boost' => ['sally mcmanus', 'the IQEZ iPhone app']
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->get('https://api.assemblyai.com/v2/transcript/YOUR-TRANSCRIPT-ID-HERE', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/transcript', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'audio_url' => 'https://s3-us-west-2.amazonaws.com/blog.assemblyai.com/audio/8-7-2018-post/7510.mp3',
'language_model' => 'assemblyai_media'
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/transcript', [
'headers' => [
'authorization' => 'YOUR-API-KEY',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'audio_url' => 'https://app.assemblyai.com/static/media/phone_demo_clip_1.wav',
'word_boost' => ['sally mcmanus', 'the IQEZ iPhone app'],
'boost_param' => 'high'
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/lang-model', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'name' => 'foo_bar',
'text' => [
'I want to cancel my account.',
'Welcome to Verizon how can I help you',
'CT Scan'
],
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/transcript', [
'headers' => [
'authorization' => 'YOUR-API-KEY',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'audio_url' => 'https://s3-us-west-2.amazonaws.com/blog.assemblyai.com/audio/8-7-2018-post/7510.mp3',
'punctuate' => false ,
'format_text' => false
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->get('https://api.assemblyai.com/v2/lang-model/YOUR-LANG-MODEL-ID-HERE', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/transcript', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'audio_url' => 'https://s3-us-west-2.amazonaws.com/blog.assemblyai.com/audio/8-7-2018-post/7510.mp3',
'webhook_url' => 'https://yoururl.com/foo'
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/transcript', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'audio_url' => 'https://app.assemblyai.com/static/media/phone_demo_clip_1.wav',
'dual_channel' => true
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/transcript', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'audio_url' => 'https://cdn.assemblyai.com/upload/ccbbbfaf-f319-4455-9556-272d48faaf7f'
],
]);
echo $response->getBody();
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/transcript', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
\GuzzleHttp\RequestOptions::JSON => [
'audio_url' => 'https://s3-us-west-2.amazonaws.com/blog.assemblyai.com/audio/8-7-2018-post/7510.mp3',
'acoustic_model' => 'assemblyai_en_au'
],
]);
echo $response->getBody();
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.assemblyai.com/v2/upload',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => file_get_contents('/path/to/your/audio.wav'),
CURLOPT_HTTPHEADER => array(
'authorization: YOUR-API-TOKEN',
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo 'cURL Error #:' . $err;
} else {
echo $response;
}
<?php
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api.assemblyai.com/v2/upload', [
'headers' => [
'authorization' => 'YOUR-API-TOKEN',
'content-type' => 'application/json'
],
'body' => fopen('test1.m4a', 'r')
]);
echo $response->getBody();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment