LlamaIndex Python Integration with AssemblyAI
You can use the AssemblyAI Audio Transcript Loader from LlamaHub to transcribe audio files inside your LlamaIndex applications.
Looking for the JavaScript integration? Check out the LlamaIndex.TS integration.
Quickstart
First, install the assemblyai
python package.
Set your AssemblyAI API key as an environment variable named ASSEMBLYAI_API_KEY
. You can get a free AssemblyAI API key from the AssemblyAI dashboard.
- To load and transcribe audio data into documents,
- Configure the
file_path
argument with a URL or a local file path to an audio or video file.
reader.load_data()
waits until the transcription is ready.
The reader.load_data()
method returns an array of documents, but by default, thereβs only one document in the array with the full transcript.
The transcribed text is available in the text
attribute:
The metadata
contains the full transcript object with more meta information:
Transcript formats
You can specify the transcript_format
argument to load the transcript in different formats.
Depending on the format, load_data()
returns either one or more documents. These are the different TranscriptFormat
options:
TEXT
: One document with the transcription textSENTENCES
: Multiple documents, splits the transcription by each sentencePARAGRAPHS
: Multiple documents, splits the transcription by each paragraphSUBTITLES_SRT
: One document with the transcript exported in SRT subtitles formatSUBTITLES_VTT
: One document with the transcript exported in VTT subtitles format
Transcription config
You can also specify the config
argument to use different audio intelligence models.
Pass the API key as argument
You can also pass the AssemblyAI API key as an argument instead of an environment variable.
Additional resources
You can learn more about using LlamaIndex with AssemblyAI in these resources.