Python SDK Reference
Installation
How the SDK handles Default Configurations
Defining Defaults
When no TranscriptionConfig
is being passed to the Transcriber
or its methods, it will use a default instance of a TranscriptionConfig
.
If you would like to re-use the same TranscriptionConfig
for all your transcriptions,
you can set it on the Transcriber
directly:
Overriding Defaults
You can override the default configuration later via the .config
property of the Transcriber
:
In case you want to override the Transcriber
’s configuration for a specific operation with a different one, you can do so via the config
parameter of a .transcribe*(...)
method:
Synchronous vs Asynchronous
Currently, the SDK provides two ways to transcribe audio files.
The synchronous approach halts the application’s flow until the transcription has been completed.
The asynchronous approach allows the application to continue running while the transcription is being processed. The caller receives a concurrent.futures.Future
object which can be used to check the status of the transcription at a later time.
You can identify those two approaches by the _async
suffix in the Transcriber
’s method name (e.g. transcribe
vs transcribe_async
).
Getting the HTTP status code
There are two ways of accessing the HTTP status code:
- All custom AssemblyAI Error classes have a
status_code
attribute. - The latest HTTP response is stored in
aai.Client.get_default().latest_response
after every API call. This approach works also if no Exception is thrown.
Polling Intervals
By default we poll the Transcript
’s status each 3s
. In case you would like to adjust that interval:
Retrieving Existing Transcripts
Retrieving a Single Transcript
If you previously created a transcript, you can use its ID to retrieve it later.
Retrieving Multiple Transcripts as a Group
You can also retrieve multiple existing transcripts and combine them into a single TranscriptGroup
object. This allows you to perform operations on the transcript group as a single unit, such as querying the combined transcripts with LeMUR.
Retrieving Transcripts Asynchronously
Both Transcript.get_by_id
and TranscriptGroup.get_by_ids
have asynchronous counterparts, Transcript.get_by_id_async
and TranscriptGroup.get_by_ids_async
, respectively. These functions immediately return a Future
object, rather than blocking until the transcript(s) are retrieved.
See the above section on Synchronous vs Asynchronous for more information.