Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -28,7 +28,6 @@ def merge_entities(entities):
|
|
28 |
current = next_entity
|
29 |
merged.append(current)
|
30 |
return merged
|
31 |
-
|
32 |
def transcribe_audio(audio_path):
|
33 |
"""
|
34 |
Transcribe a local audio file using the Whisper pipeline, log timing, and save transcription to a file.
|
@@ -40,6 +39,9 @@ def transcribe_audio(audio_path):
|
|
40 |
# Ensure audio is mono and resampled to 16kHz
|
41 |
audio, sr = librosa.load(audio_path, sr=16000, mono=True)
|
42 |
|
|
|
|
|
|
|
43 |
# Perform transcription
|
44 |
transcription = whisper_pipeline_agri(audio, batch_size=8)["text"]
|
45 |
|
@@ -51,6 +53,7 @@ def transcribe_audio(audio_path):
|
|
51 |
except Exception as e:
|
52 |
return f"Error processing audio: {e}"
|
53 |
|
|
|
54 |
def translate_text_to_english(text):
|
55 |
"""
|
56 |
Translate text into English using GoogleTranslator.
|
|
|
28 |
current = next_entity
|
29 |
merged.append(current)
|
30 |
return merged
|
|
|
31 |
def transcribe_audio(audio_path):
|
32 |
"""
|
33 |
Transcribe a local audio file using the Whisper pipeline, log timing, and save transcription to a file.
|
|
|
39 |
# Ensure audio is mono and resampled to 16kHz
|
40 |
audio, sr = librosa.load(audio_path, sr=16000, mono=True)
|
41 |
|
42 |
+
# Set the pad token for batching
|
43 |
+
whisper_pipeline_agri.tokenizer.pad_token_id = whisper_pipeline_agri.model.config.eos_token_id
|
44 |
+
|
45 |
# Perform transcription
|
46 |
transcription = whisper_pipeline_agri(audio, batch_size=8)["text"]
|
47 |
|
|
|
53 |
except Exception as e:
|
54 |
return f"Error processing audio: {e}"
|
55 |
|
56 |
+
|
57 |
def translate_text_to_english(text):
|
58 |
"""
|
59 |
Translate text into English using GoogleTranslator.
|