1. Go to this page and download the library: Download streams-sro/gaston library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
streams-sro / gaston example snippets
use StreamsSro\Gaston\GastonClient;
$client = new GastonClient('gapi-...');
// Who am I + remaining quota
$me = $client->me();
echo $me->email, ' files left: ', $me->usage->filesLeft, PHP_EOL;
// Transcribe a local file
$result = $client->transcribe('interview.mp4', 'en', null, 'My interview');
echo $result->id, ' ', $result->state, PHP_EOL;
// Transcribe from a URL (YouTube or web)
$client->transcribeUrl('https://youtu.be/dQw4w9WgXcQ', 'en');
// Translate an existing transcription
$client->translate($result->id, 'de');
// Word-level alignment of a translation against source timestamps
// (mate change', 0, 20);
echo 'total matches: ', $results->total, PHP_EOL;
foreach ($results as $hit) {
echo $hit['_sentence']['body'], ' -> ', implode(' ', $hit['_highlight']['body']), PHP_EOL;
}
new GastonClient(
string $token = null, // falls back to GASTON_API_TOKEN
float $timeout = 30.0, // ordinary requests, seconds (0 = no limit)
float $uploadTimeout = 600.0, // file uploads and audio exports, seconds
float $connectTimeout = 10.0, // connection timeout, seconds
HttpClientInterface $httpClient = null
);
// Uses GASTON_API_TOKEN from the environment
$client = new GastonClient();
// Customise the defaults for all calls
$client = new GastonClient('gapi-...', 30.0, 1800.0); // up to 30 min uploads
// Or override per call (e.g. no timeout for a very large file)
$client->transcribe('huge-recording.mp4', null, null, null, 0.0);
// Transcript as plain text (format: text, text_timestamps, csv, srt, audio)
$export = $client->exportMedia('me...', 'text', 'en');
echo $export->filename, PHP_EOL; // filename suggested by the server, e.g. "My interview.txt"
echo $export->content;
// Subtitles split into blocks of at most 8 words, prefixed with speaker names
// (speaker names
$folder = $client->createDirectory('Podcasts');
$client->updateDirectory($folder->id, 'Podcast archive');
$moved = $client->moveMedia('me...', $folder->id); // returns the updated Media
$tree = $client->directoryTree();
$client->deleteDirectory($folder->id);
$results = $client->search('(invoice OR receipt) AND "due date" NOT draft');
// Search within a single directory
$client->search('budget', 0, 50, [42]);
// Search across several directories
$client->search('budget', 0, 50, [42, 43, 7]);
// Restrict to one language, and page through results
$page2 = $client->search('budget', 50, 50, null, 'en');
// Search within a single media
$client->search('budget', 0, 50, null, null, 'me...');