Skip to main content
def stt_transcribe(client: Cartesia) -> None:
    """Transcribe audio with word timestamps."""
    with open("audio.wav", "rb") as f:
        response = client.stt.transcribe(
            file=f,
            model="ink-whisper",
            language="en",
            timestamp_granularities=["word"],  # Optional: get word timestamps
        )
    print(response.text)
    if response.words:
        for word in response.words:
            print(f"{word.word}: {word.start}s - {word.end}s")
From cartesia-python/examples/examples.py:526

Run this example

cd cartesia-python
CARTESIA_API_KEY=YOUR_KEY python3 examples/examples.py stt_transcribe