Spaces:
Runtime error
Runtime error
Commit
·
30e5ade
1
Parent(s):
bad795e
Update app.py
Browse files
app.py
CHANGED
@@ -12,9 +12,16 @@ model = CombinedModel("facebook/mms-1b-all", "Sunbird/sunbird-mul-en-mbart-merge
|
|
12 |
def preprocess_audio(audio_file):
|
13 |
speech, sample_rate = librosa.load(audio_file, sr=16000, mono=True)
|
14 |
chunk_size = 10 * 16000
|
15 |
-
chunks = [
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
return chunks
|
17 |
|
|
|
18 |
def transcribe(chunks):
|
19 |
transcriptions = []
|
20 |
translations = []
|
|
|
12 |
def preprocess_audio(audio_file):
|
13 |
speech, sample_rate = librosa.load(audio_file, sr=16000, mono=True)
|
14 |
chunk_size = 10 * 16000
|
15 |
+
chunks = []
|
16 |
+
for i in range(0, len(speech), chunk_size):
|
17 |
+
chunk = speech[i:i + chunk_size]
|
18 |
+
if len(chunk) < chunk_size:
|
19 |
+
# Pad the last chunk if its duration is less than 10 seconds
|
20 |
+
chunk = np.pad(chunk, (0, chunk_size - len(chunk)))
|
21 |
+
chunks.append(chunk)
|
22 |
return chunks
|
23 |
|
24 |
+
|
25 |
def transcribe(chunks):
|
26 |
transcriptions = []
|
27 |
translations = []
|