Download the PHP package streams-sro/gaston without Composer
On this page you can find all versions of the php package streams-sro/gaston. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download streams-sro/gaston
More information about streams-sro/gaston
Files in streams-sro/gaston
Package gaston
Short Description PHP client for the Gaston API (transcription, translation and sentence search).
License MIT
Homepage https://gaston.live
Informations about the package gaston
Gaston API Client (PHP)
A small, dependency-free PHP client for the Gaston API: transcription, translation and full-text search of sentences within transcribed recordings.
Requires a Gaston account and an API token (see Configuration).
This is a PHP port of the official Python client and tracks the same API.
Requirements
- PHP 7.0+
- The
curlandjsonextensions (both bundled with PHP by default)
No third-party runtime dependencies.
Installation
Quick start
The constructor signature is:
Configuration
Generate an API token in the Gaston app under Settings -> API. Full endpoint documentation is available at https://www.gaston.live/en/api.
The token can be supplied directly or via the GASTON_API_TOKEN environment
variable:
| Argument | Environment variable | Default |
|---|---|---|
$token |
GASTON_API_TOKEN |
(required) |
Timeouts
Ordinary requests use a 30s timeout. The file upload in transcribe() and
audio exports can take minutes for large files, so they use a separate, more
generous $uploadTimeout (default 600s). All timeouts are in seconds; pass 0 to wait indefinitely.
transcribe() accepts either a file path or an open stream resource:
Exporting
exportMedia() returns the file in memory as a MediaExport (->content,
->filename, ->contentType, plus ->save($path)), while
exportMediaToFile() streams it straight to disk. Use exportMediaToFile() for
audio.
The full signatures are:
$lang defaults to the media's original language. $maxWordsPerBlock and
$includeSpeakers only apply to srt. Exporting audio, or any media longer
than 30 minutes, requires a paid plan; otherwise an AuthenticationException
(HTTP 403) is thrown. Audio exports use the client's $uploadTimeout by
default. exportMediaToFile() downloads to a temporary file next to the target
first, so a failed export never leaves a partial file behind. The supported
formats are listed in Languages::EXPORT_FORMATS.
Directories
Search
$client->search($query, $from = 0, $max = 50, $dirIds = null, $lang = null, $mediaId = null)
runs a full-text search over every sentence in your transcribed media.
Query syntax
The query supports a subset of the Lucene query_string syntax:
| Feature | Example | Notes |
|---|---|---|
Boolean AND |
cats AND dogs |
both terms must appear |
Boolean OR |
cats OR dogs |
either term |
Boolean NOT |
cats NOT dogs |
exclude a term |
| Grouping | (cats OR dogs) AND vet |
combine operators with parentheses |
| Exact phrase | "climate change" |
quoted terms match as a phrase |
| Trailing wildcard | transcri* |
matches transcribe, transcription... |
Leading wildcards (*tion), field selectors, fuzzy (~), boosts (^) and
ranges are not supported and are stripped server-side. Queries must be at least
3 characters.
Filtering and pagination
Reading results
search() returns a SearchResults object. Iterate it for hits, or read
->total for the overall match count. Each hit is an array with:
_sentence- the matched sentence plus itsmediametadata (id, title, duration, directory, thumbnail, file, originUrl)._highlight- matched fragments with the hit terms wrapped in<hlt>...</hlt>tags.
Error handling
All failures throw a subclass of GastonException:
| Exception | Trigger |
|---|---|
AuthenticationException |
HTTP 403, invalid token / disabled user |
BadRequestException |
HTTP 400, invalid parameters |
NotFoundException |
HTTP 404, resource not found |
RateLimitException |
HTTP 429, usage limit exceeded |
ExternalServiceException |
HTTP 502, an external dependency failed upstream |
GastonApiException |
any other API error |
Every API exception carries ->getStatusCode(), ->getMessage(),
->getDetails() and the raw ->getPayload(). GastonException is the base
class for all of the above (including transport-level failures).
Supported languages
Development
The test suite uses PHPUnit (a dev-only dependency; the library itself has none):
License
MIT - see LICENSE.
All versions of gaston with dependencies
ext-curl Version *
ext-json Version *