DEV Community

shashank ms
shashank ms

Posted on

Using LLMs for Audio Analysis

We are building a command-line audio analyzer that transcribes voice recordings and extracts structured insights like sentiment, key topics, and action items. It is useful for support teams, product managers, or researchers who need to turn hours of recordings into concise reports without manual note-taking.

What you'll need

  • Python 3.10 or newer
  • The OpenAI SDK: pip install openai
  • An Oxlo.ai API key from https://portal.oxlo.ai
  • A sample audio file in MP3 or WAV format

Step 1: Transcribe the audio

Oxlo.ai hosts Whisper Large v3 behind an OpenAI-compatible audio/transcriptions endpoint. I open the audio file in binary mode and post it just like I would to any OpenAI-compatible provider, but the request routes to Oxlo.ai.

from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

AUDIO_FILE = "meeting.mp3"

with open(AUDIO_FILE, "rb") as audio:
    transcript = client.audio.transcriptions.create(
        model="whisper-large-v3",
        file=audio,
        response_format="text"
    )

print(transcript)

Step 2: Define the analysis prompt

I want consistent, structured output every time. A strong system prompt keeps the LLM from drifting into commentary or inventing facts.

SYSTEM_PROMPT = """You are an audio analysis assistant. Read the transcript and emit a structured report.

Use this exact format:
- Summary: One paragraph.
- Sentiment: Positive, Neutral, or Negative.
- Key Topics: Bullet list of main themes.
- Action Items: Bullet list of tasks with owners if stated.
- Open Questions: Any unresolved questions.

Do not invent information. If a section has no data, write "None found"."""

Step 3: Analyze the transcript

I pass the transcript to Llama 3.3 70B on Oxlo.ai. Because Oxlo.ai uses request-based pricing, the cost is the same whether the transcript is ten lines or ten thousand lines, which keeps this pattern economical for long recordings.

response = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[
        {"role": "system", "content": SYSTEM_PROMPT},
        {"role": "user", "content": f"Analyze this transcript:\n\n{transcript}"},
    ],
)

report = response.choices[0].message.content
print(report)

Step 4: Wrap it in a CLI

I combine both steps into a single script so I can run it against any file. I also add a small helper to optionally save the report to disk.

import argparse
from pathlib import Path
from openai import OpenAI

client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")

SYSTEM_PROMPT = """You are an audio analysis assistant. Read the transcript and emit a structured report.

Use this exact format:
- Summary: One paragraph.
- Sentiment: Positive, Neutral, or Negative.
- Key Topics: Bullet list of main themes.
- Action Items: Bullet list of tasks with owners if stated.
- Open Questions: Any unresolved questions.

Do not invent information. If a section has no data, write "None found"."""

def analyze_audio(audio_path: str, out_path: str | None = None):
    with open(audio_path, "rb") as audio:
        transcript = client.audio.transcriptions.create(
            model="whisper-large-v3",
            file=audio,
            response_format="text"
        )

    response = client.chat.completions.create(
        model="llama-3.3-70b",
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": f"Analyze this transcript:\n\n{transcript}"},
        ],
    )

    report = response.choices[0].message.content

    if out_path:
        Path(out_path).write_text(report)
        print(f"Report saved to {out_path}")
    else:
        print(report)

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="Analyze audio with Oxlo.ai")
    parser.add_argument("audio", help="Path to mp3/wav file")
    parser.add_argument("--out", help="Optional output file")
    args = parser.parse_args()

    analyze_audio(args.audio, args.out)

Run it

Save the full script as audio_analyzer.py and point it at a recording.

$ python audio_analyzer.py earnings_call.mp3 --out report.txt

Report saved to report.txt

$ cat report.txt
- Summary: The team reviewed Q3 metrics, noting a 12% revenue increase and delayed feature rollout.
- Sentiment: Neutral.
- Key Topics: Q3 revenue, mobile app redesign, hiring pipeline.
- Action Items: Engineering to finalize rollout by Oct 15 (Sarah). Recruiting to open three senior roles (Mike).
- Open Questions: None found.

Next steps

Swap llama-3.3-70b for kimi-k2.6 if you need stronger reasoning on technical conversations, or batch-process an entire folder of recordings and write results to a SQLite database. If you plan to run this at scale, compare Oxlo.ai request-based pricing against token-based providers for long transcripts at https://oxlo.ai/pricing.

Top comments (0)