Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,8 @@ import gradio as gr
|
|
| 2 |
from address_extractor import AddressExtractor
|
| 3 |
import tempfile
|
| 4 |
import os
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Instantiate your AddressExtractor class
|
| 7 |
address_extractor = AddressExtractor()
|
|
@@ -32,6 +34,8 @@ def extract_from_audio(audio_file):
|
|
| 32 |
# tmp_file_path = tmp_file.name
|
| 33 |
|
| 34 |
try:
|
|
|
|
|
|
|
| 35 |
# segments = address_extractor.whisper_model.transcribe(tmp_file_path)
|
| 36 |
segments = address_extractor.whisper_model.transcribe(audio_file)
|
| 37 |
input_text = " ".join([seg.text.strip() for seg in segments])
|
|
|
|
| 2 |
from address_extractor import AddressExtractor
|
| 3 |
import tempfile
|
| 4 |
import os
|
| 5 |
+
import librosa
|
| 6 |
+
import soundfile as sf
|
| 7 |
|
| 8 |
# Instantiate your AddressExtractor class
|
| 9 |
address_extractor = AddressExtractor()
|
|
|
|
| 34 |
# tmp_file_path = tmp_file.name
|
| 35 |
|
| 36 |
try:
|
| 37 |
+
audio, sr = librosa.load(audio_file, sr=16000)
|
| 38 |
+
sf.write(audio_file, audio, 16000)
|
| 39 |
# segments = address_extractor.whisper_model.transcribe(tmp_file_path)
|
| 40 |
segments = address_extractor.whisper_model.transcribe(audio_file)
|
| 41 |
input_text = " ".join([seg.text.strip() for seg in segments])
|