Spaces:
Sleeping
Sleeping
| import os | |
| from llama_index.readers.assemblyai import AssemblyAIAudioTranscriptReader | |
| from llama_index.core.tools import FunctionTool | |
| def transcribe_audio(audio_file_path: str) -> str: | |
| """ | |
| Transcribes audio file and returns the transcript string as output. | |
| Args: | |
| audio_file_path (str): Local path to the audio file | |
| """ | |
| reader = AssemblyAIAudioTranscriptReader(api_key= os.getenv("ASSEMBLYAI_API_KEY") ,file_path=audio_file_path) | |
| docs = reader.load_data() | |
| return docs[0].text | |
| def get_transcribe_audio() -> FunctionTool: | |
| return FunctionTool.from_defaults( | |
| fn=transcribe_audio, | |
| name="audio_file_transcriber", | |
| description="A tool that transcribes audio files (such as mp3). It takes the file_path to the downloaded audio file and returns the transcripts." | |
| ) |