Update asr.py
Browse files
asr.py
CHANGED
@@ -7,6 +7,7 @@ logging.basicConfig(level=logging.DEBUG)
|
|
7 |
|
8 |
ASR_SAMPLING_RATE = 16_000
|
9 |
MODEL_ID = "facebook/mms-1b-all"
|
|
|
10 |
|
11 |
try:
|
12 |
# Create the pipeline with the appropriate model
|
@@ -26,6 +27,8 @@ def transcribe(audio):
|
|
26 |
# Try loading the audio file with librosa
|
27 |
try:
|
28 |
audio_samples, _ = librosa.load(audio, sr=ASR_SAMPLING_RATE, mono=True)
|
|
|
|
|
29 |
except FileNotFoundError:
|
30 |
logging.error("Audio file not found")
|
31 |
return "ERROR: Audio file not found"
|
|
|
7 |
|
8 |
ASR_SAMPLING_RATE = 16_000
|
9 |
MODEL_ID = "facebook/mms-1b-all"
|
10 |
+
LANGUAGE_CODE = "fao" # Faroese language code
|
11 |
|
12 |
try:
|
13 |
# Create the pipeline with the appropriate model
|
|
|
27 |
# Try loading the audio file with librosa
|
28 |
try:
|
29 |
audio_samples, _ = librosa.load(audio, sr=ASR_SAMPLING_RATE, mono=True)
|
30 |
+
if len(audio_samples) == 0:
|
31 |
+
raise ValueError("Audio samples are empty")
|
32 |
except FileNotFoundError:
|
33 |
logging.error("Audio file not found")
|
34 |
return "ERROR: Audio file not found"
|