Get Started

This short tutorial will teach you the basics of using the Rev AI Python SDK. It demonstrates how to produce a transcript of an audio file submitted by you using the SDK.

Assumptions

This tutorial assumes that:

Step 1: Install the SDK

Begin by installing the SDK:

Copy
Copied
pip install --upgrade rev_ai

Step 2: Submit a file for transcription and retrieve the result

The following example demonstrates how to submit a local audio file for transcription.

To use this example, replace the <FILEPATH> placeholder with the path to the file you wish to transcribe and the <REVAI_ACCESS_TOKEN> placeholder with your Rev AI account's access token.

Copy
Copied
from rev_ai import apiclient

token = "<REVAI_ACCESS_TOKEN>"
filePath = "<FILEPATH>"

# create your client
client = apiclient.RevAiAPIClient(token)

# send a local file
job = client.submit_job_local_file(filePath)

# check job status
job_details = client.get_job_details(job.id)

# retrieve transcript as text
transcript_text = client.get_transcript_text(job.id)

# retrieve transcript as JSON
transcript_json = client.get_transcript_json(job.id)

# retrieve transcript as a Python object
transcript_object = client.get_transcript_object(job.id)

You can also submit a remote file .

The text output is a string containing just the text of your transcript. The object and JSON forms of the transcript contain all the information outlined in the response of the transcript retrieval endpoint of the Asynchronous Speech-to-Text API when using the JSON response schema.

Any of these outputs can also be retrieved as a stream for easy file writing:

Copy
Copied
text_stream = client.get_transcript_text_as_stream(job.id)
json_stream = client.get_transcript_json_as_stream(job.id)

In these cases, the SDK returns the raw HTTP response. The output can be retrieved via response.content, response.iter_lines() or response.iter_content().

Next steps

You should now have a basic understanding of how to use the Python SDK. To learn more, refer to the SDK documentation and code samples.