Summarize your audio data

In this guide, you’ll learn how to use LeMUR to summarize your audio data with key takeaways.

If you want a Quickstart, see Apply LLMs to audio files.

Before you start

To use LeMUR, you need an AssemblyAI account with a credit card set up.

Basic summary example

If you want to send a custom prompt to the LLM, you can use the LeMUR Task and apply the model to your transcribed audio files.

To summarize the content in your audio data, define a summarization prompt and call transcript.lemur.task(). The underlying transcript is automatically used as additional context for the model.

1import assemblyai as aai
2
3aai.settings.api_key = "<YOUR_API_KEY>"
4
5# Step 1: Transcribe an audio file.
6# audio_file = "./local_file.mp3"
7audio_file = "https://assembly.ai/sports_injuries.mp3"
8
9transcriber = aai.Transcriber()
10transcript = transcriber.transcribe(audio_file)
11
12# Step 2: Define a summarization prompt.
13prompt = "Provide a brief summary of the transcript."
14
15# Step 3: Apply LeMUR.
16result = transcript.lemur.task(
17 prompt, final_model=aai.LemurModel.claude3_5_sonnet
18)
19
20print(result.response)

Example output

1The transcript describes several common sports injuries - runner's knee,
2sprained ankle, meniscus tear, rotator cuff tear, and ACL tear. It provides
3definitions, causes, and symptoms for each injury. The transcript seems to be
4narrating sports footage and describing injuries as they occur to the athletes.
5Overall, it provides an overview of these common sports injuries that can result
6from overuse or sudden trauma during athletic activities

Summary with specialized endpoint

The LeMUR Summary function requires no prompt engineering and facilitates more deterministic and structured outputs. See the code examples below for more information on how to use this endpoint.

You can add additional context to provide information that is not explicitly referenced in the audio data, as well as specify an answer format. For this, use the optional parameters context and answer_format.

1import assemblyai as aai
2
3aai.settings.api_key = "<YOUR_API_KEY>"
4
5audio_url = "https://assembly.ai/meeting.mp4"
6transcript = aai.Transcriber().transcribe(audio_url)
7
8result = transcript.lemur.summarize(
9 final_model=aai.LemurModel.claude3_5_sonnet,
10 context="A GitLab meeting to discuss logistics",
11 answer_format="TLDR"
12)
13
14print(result.response)

Custom summary example (Advanced)

In this example, we’ll run a custom LeMUR task with an advanced prompt to create custom summaries:

Cookbook: Custom summary with LeMUR Task

More summarization prompt examples

Try any of these prompts to get started:

Use caseExample prompt
Summaries”Summarize key decisions and important points from the phone call transcript”
Summarize audio segments”Summarize the key events of each chapter”

For more use cases and prompt examples, see LeMUR examples.

API reference

Improve the results

To improve the results, see the following resources:

Built with