| 134 | |
| 135 | |
| 136 | class AudioReader(Reader): |
| 137 | @staticmethod |
| 138 | def parse(file_path: Path) -> str: |
| 139 | logger.info(f"Transcribing audio file from {file_path}.") |
| 140 | client = OpenAI(api_key=OPENAI_API_KEY) |
| 141 | try: |
| 142 | client = OpenAI() |
| 143 | with open(file_path, "rb") as audio_file: |
| 144 | transcript = client.audio.translations.create( |
| 145 | model="whisper-1", |
| 146 | file=audio_file |
| 147 | ) |
| 148 | return transcript.text |
| 149 | except Exception as e: |
| 150 | logger.info(f"Error transcribing audio file: {e}") |
| 151 | return "Error transcribing audio file." |
| 152 | |
| 153 | class PPTXReader(Reader): |
| 154 | def parse(self, file_path: Path) -> str: |