Triton AI Docs

Speech to text

Transcribe an audio file with Python or cURL.

Convert speech to text with api-cohere-transcribe. Your API key must have access to this model.

Transcribe an audio file

Set the transcription model to api-cohere-transcribe.

Download speech.wav to your working directory, or use your own recording.

transcribe.py
import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["TRITONAI_API_KEY"],
    base_url="https://tritonai-api.ucsd.edu/v1",
)

with open("speech.wav", "rb") as audio_file:
    transcript = client.audio.transcriptions.create(
        model="api-cohere-transcribe",
        file=audio_file,
    )

print(transcript.text)

Read the response

The response contains a text field. The Python client exposes it as transcript.text.

This response came from a test WAV containing "The library opens at nine in the morning."

{
  "text": "The library opens at nine in the morning.",
  "usage": {
    "type": "duration",
    "seconds": 3.0
  }
}

Prepare the file

Use a non-empty recording. The example was tested with a mono, 16-bit PCM WAV at 16 kHz.

Keep audio within your approved data use. Do not send P4 information.

See the transcription reference for request fields and the response schema.

On this page