Update app.py
Browse files
app.py
CHANGED
@@ -22,13 +22,18 @@ audio_processor = Audio()
|
|
22 |
|
23 |
# Function to process the audio file and extract transcript and diarization
|
24 |
def process_audio(audio_file, num_speakers, model_size="medium", language="English"):
|
25 |
-
#
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
print(f"Audio file saved to: {path}")
|
31 |
-
|
32 |
# Convert audio to WAV if it's not already
|
33 |
if path[-3:] != 'wav':
|
34 |
wav_path = path.replace(path.split('.')[-1], 'wav')
|
@@ -57,6 +62,9 @@ def process_audio(audio_file, num_speakers, model_size="medium", language="Engli
|
|
57 |
# Remaining processing code...
|
58 |
|
59 |
|
|
|
|
|
|
|
60 |
# Get audio duration
|
61 |
with contextlib.closing(wave.open(path, 'r')) as f:
|
62 |
frames = f.getnframes()
|
|
|
22 |
|
23 |
# Function to process the audio file and extract transcript and diarization
|
24 |
def process_audio(audio_file, num_speakers, model_size="medium", language="English"):
|
25 |
+
# Check if the audio_file is a file-like object (it should be)
|
26 |
+
if isinstance(audio_file, str):
|
27 |
+
# If it's a string (path), open the file from the path
|
28 |
+
path = audio_file # directly use the path if it's a string
|
29 |
+
else:
|
30 |
+
# Otherwise, handle it as a file-like object
|
31 |
+
path = "/tmp/uploaded_audio.wav"
|
32 |
+
with open(path, "wb") as f:
|
33 |
+
f.write(audio_file.read()) # read from the file-like object
|
34 |
+
|
35 |
print(f"Audio file saved to: {path}")
|
36 |
+
|
37 |
# Convert audio to WAV if it's not already
|
38 |
if path[-3:] != 'wav':
|
39 |
wav_path = path.replace(path.split('.')[-1], 'wav')
|
|
|
62 |
# Remaining processing code...
|
63 |
|
64 |
|
65 |
+
# Remaining processing code...
|
66 |
+
|
67 |
+
|
68 |
# Get audio duration
|
69 |
with contextlib.closing(wave.open(path, 'r')) as f:
|
70 |
frames = f.getnframes()
|