Package: llama-index-readers-assemblyai
AssemblyAI Audio Transcript LoaderThe AssemblyAI Audio Transcript Loader allows to transcribe audio files with theAssemblyAI APIand loads the transcribed text into documents.To use it, you should have theassemblyaipython package installed, and the environment variableASSEMBLYAI_API_KEYset with your API key. Alternatively, the API key can also be passed as an argument.More info about AssemblyAI:WebsiteGet a Free API keyAssemblyAI API DocsInstallationFirst, you need to install theassemblyaipython package.You can find more info about it inside theassemblyai-python-sdk GitHub repo.pipinstallassemblyaiOptionally: You can install the AssemblyAI integration yourself with:pipinstallllama-index-readers-assemblyaiThen you can import it with:fromllama_index.readers.assemblyaiimportAssemblyAIAudioTranscriptReaderAs an alternative, you can also use thedownload_loader()to install and use this integration (see next section).UsageTheAssemblyAIAudioTranscriptReaderneeds at least thefile_pathargument. Audio files can be specified as an URL or a local file path.fromllama_index.coreimportdownload_loaderAssemblyAIAudioTranscriptReader=download_loader("AssemblyAIAudioTranscriptReader")audio_file="https://storage.googleapis.com/aai-docs-samples/nbc.mp3"# or a local file path: audio_file = "./nbc.mp3"reader=AssemblyAIAudioTranscriptReader(file_path=audio_file)docs=reader.load_data()Note: Callingreader.load_data()blocks until the transcription is finished.The transcribed text is available in thetext:docs[0].text# "Load time, a new president and new congressional makeup. Same old ..."Themetadatacontains the full JSON response with more meta information:docs[0].metadata# {'language_code': <LanguageCode.en_us: 'en_us'>,#  'audio_url': 'https://storage.googleapis.com/aai-docs-samples/nbc.mp3',#  'punctuate': True,#  'format_text': True,#   ...# }Transcript FormatsYou can specify thetranscript_formatargument for different formats.Depending on the format, one or more documents are returned. These are the differentTranscriptFormatoptions: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 formatfromllama_index.readers.assemblyaiimportTranscriptFormatreader=AssemblyAIAudioTranscripReader(file_path="./your_file.mp3",transcript_format=TranscriptFormat.SENTENCES,)docs=reader.load_data()Transcription ConfigYou can also specify theconfigargument to use different audio intelligence models.Visit theAssemblyAI API Documentationto get an overview of all available models!importassemblyaiasaaiconfig=aai.TranscriptionConfig(speaker_labels=True,auto_chapters=True,entity_detection=True)reader=AssemblyAIAudioTranscriptReader(file_path="./your_file.mp3",config=config)Pass the API Key as argumentNext to setting the API key as environment variableASSEMBLYAI_API_KEY, it is also possible to pass it as argument.reader=AssemblyAIAudioTranscriptReader(file_path="./your_file.mp3",api_key="YOUR_KEY")