Spaces:
Runtime error
Runtime error
Fix import error
Browse files- transcribe.py +20 -0
transcribe.py
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
def transcribe_audio_locally(audio_file_path, model_size="base"):
|
| 2 |
+
"""
|
| 3 |
+
Transcribe audio using locally installed Whisper
|
| 4 |
+
|
| 5 |
+
Args:
|
| 6 |
+
audio_file_path (str): Path to audio file
|
| 7 |
+
model_size (str): Whisper model size (tiny, base, small, medium, large)
|
| 8 |
+
|
| 9 |
+
Returns:
|
| 10 |
+
dict: Transcription result containing text and other info
|
| 11 |
+
"""
|
| 12 |
+
import whisper
|
| 13 |
+
|
| 14 |
+
# Load the model
|
| 15 |
+
model = whisper.load_model(model_size)
|
| 16 |
+
|
| 17 |
+
# Transcribe the audio
|
| 18 |
+
result = model.transcribe(audio_file_path)
|
| 19 |
+
|
| 20 |
+
return result
|