Spaces:
Sleeping
Sleeping
Dhairyashil Ghatage commited on
Commit ·
bdb7fbc
1
Parent(s): f8d2bd6
update whisper load
Browse files
app.py
CHANGED
|
@@ -184,8 +184,17 @@ whole_model.load_state_dict(state_dict, strict=False)
|
|
| 184 |
# Set the model to evaluation mode
|
| 185 |
whole_model.eval()
|
| 186 |
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
def transcribe_audio(audio):
|
| 191 |
if isinstance(audio, str): # If it's a file path
|
|
|
|
| 184 |
# Set the model to evaluation mode
|
| 185 |
whole_model.eval()
|
| 186 |
|
| 187 |
+
whisper_model_path = "whisper-small-local"
|
| 188 |
+
if os.path.exists(whisper_model_path):
|
| 189 |
+
#print("Loading Whisper model from local storage...")
|
| 190 |
+
whisper_model = WhisperForConditionalGeneration.from_pretrained(whisper_model_path)
|
| 191 |
+
whisper_processor = WhisperProcessor.from_pretrained(whisper_model_path)
|
| 192 |
+
else:
|
| 193 |
+
print("Downloading Whisper model from Hugging Face...")
|
| 194 |
+
whisper_model = WhisperForConditionalGeneration.from_pretrained("openai/whisper-small")
|
| 195 |
+
whisper_processor = WhisperProcessor.from_pretrained("openai/whisper-small")
|
| 196 |
+
|
| 197 |
+
|
| 198 |
|
| 199 |
def transcribe_audio(audio):
|
| 200 |
if isinstance(audio, str): # If it's a file path
|