We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0b2234b commit 172a00bCopy full SHA for 172a00b
1 file changed
rabbithole/transcribe.py
@@ -0,0 +1,24 @@
1
+"""rabbithole.transcribe module"""
2
+
3
+import openai
4
5
+from rabbithole.mp3 import chunk_mp3
6
7
8
+def transcribe(filepath: str) -> str:
9
+ """
10
+ Transcribe a mp3 file using OpenAI's Whisper API
11
+ :param filepath: Path to mp3 file
12
+ :return: Transcription
13
14
15
+ # Split the file into chunks
16
+ files = chunk_mp3(filepath)
17
18
+ transcripts = []
19
20
+ for file in files:
21
+ with open(file, "rb") as audio_file:
22
+ transcripts.append(openai.Audio.transcribe("whisper-1", audio_file))
23
24
+ return " ".join(transcripts)
0 commit comments