Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,8 @@ import torch
|
|
4 |
import librosa
|
5 |
import json
|
6 |
|
|
|
|
|
7 |
def load_model(model_name = "cawoylel/windanam_mms-1b-tts_v2"):
|
8 |
"""
|
9 |
Function to load model from hugging face
|
@@ -32,7 +34,9 @@ def transcribe(audio_file_mic=None, audio_file_upload=None):
|
|
32 |
speech, sample_rate = librosa.load(audio_file)
|
33 |
if sample_rate != 16000:
|
34 |
speech = librosa.resample(speech, orig_sr=sample_rate, target_sr=16000)
|
35 |
-
|
|
|
|
|
36 |
return transcribe_audio(speech)
|
37 |
|
38 |
|
|
|
4 |
import librosa
|
5 |
import json
|
6 |
|
7 |
+
max_duration = int(30 * sr)
|
8 |
+
|
9 |
def load_model(model_name = "cawoylel/windanam_mms-1b-tts_v2"):
|
10 |
"""
|
11 |
Function to load model from hugging face
|
|
|
34 |
speech, sample_rate = librosa.load(audio_file)
|
35 |
if sample_rate != 16000:
|
36 |
speech = librosa.resample(speech, orig_sr=sample_rate, target_sr=16000)
|
37 |
+
duration = librosa.get_duration(speech)
|
38 |
+
if duration > 30:
|
39 |
+
speech = speech[:max_duration]
|
40 |
return transcribe_audio(speech)
|
41 |
|
42 |
|