"""
AssemblyAI — Speech-to-Text Demo
=================================
A minimal, ready-to-run example of transcribing audio with AssemblyAI.

Get an API key (free credit):
    1. Sign up at https://www.assemblyai.com/dashboard/signup
    2. Your API key is shown on the dashboard home page; copy it.

Setup:
    pip install assemblyai
    export ASSEMBLYAI_API_KEY="..."

Run:
    python assemblyai_demo.py
"""

import os
import assemblyai as aai

aai.settings.api_key = os.environ.get("ASSEMBLYAI_API_KEY")


def transcribe(audio_url: str) -> str:
    """Transcribe an audio file (URL or local path) and return the text."""
    transcriber = aai.Transcriber()
    transcript = transcriber.transcribe(audio_url)
    return transcript.text


if __name__ == "__main__":
    text = transcribe("https://assembly.ai/wildfires.mp3")
    print(text)
