Vennilavan commited on
Commit
caa019f
·
verified ·
1 Parent(s): 19f34bb

Update transcriber.py

Browse files
Files changed (1) hide show
  1. transcriber.py +16 -16
transcriber.py CHANGED
@@ -1,17 +1,17 @@
1
- import subprocess
2
- import whisper
3
- import os
4
-
5
- def extract_audio(video_path: str, audio_path: str = "temp_audio.wav") -> str:
6
- if os.path.exists(audio_path):
7
- os.remove(audio_path)
8
-
9
- command = ["ffmpeg", "-i", video_path, "-q:a", "0", "-map", "a", audio_path, "-y"]
10
- subprocess.run(command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
11
- return audio_path
12
-
13
- def transcribe_audio(audio_path: str, model_size: str = "base") -> str:
14
- model = whisper.load_model(model_size)
15
- result = model.transcribe(audio_path)
16
- transcript = result["text"]
17
  return transcript
 
1
+ import subprocess
2
+ import whisper
3
+ import os
4
+
5
+ def extract_audio(video_path: str, audio_path: str = "temp_audio.wav") -> str:
6
+ if os.path.exists(audio_path):
7
+ os.remove(audio_path)
8
+
9
+ command = ["ffmpeg", "-i", video_path, "-q:a", "0", "-map", "a", audio_path, "-y"]
10
+ subprocess.run(command, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
11
+ return audio_path
12
+
13
+ def transcribe_audio(audio_path: str, model_size: str = "tiny") -> str:
14
+ model = whisper.load_model(model_size)
15
+ result = model.transcribe(audio_path)
16
+ transcript = result["text"]
17
  return transcript