Update app.py
Browse files
app.py
CHANGED
@@ -18,15 +18,17 @@ def transcribe(microphone,file):
|
|
18 |
print("microphone: ",microphone)
|
19 |
print("uploaded file: ",file)
|
20 |
if microphone:
|
21 |
-
|
|
|
|
|
22 |
try:
|
23 |
-
audio = AudioSegment.from_file(
|
24 |
if audio.frame_rate != 16000:
|
25 |
audio = audio.set_frame_rate(16000)
|
26 |
if audio.channels != 1:
|
27 |
audio = audio.set_channels(1)
|
28 |
file = file.split(".")[0]+".wav"
|
29 |
-
audio.export(
|
30 |
except Exception as e:
|
31 |
print(e)
|
32 |
transcription= asr_model.transcribe([file])
|
|
|
18 |
print("microphone: ",microphone)
|
19 |
print("uploaded file: ",file)
|
20 |
if microphone:
|
21 |
+
file_name = microphone
|
22 |
+
elif file:
|
23 |
+
file_name = file
|
24 |
try:
|
25 |
+
audio = AudioSegment.from_file(file_name)
|
26 |
if audio.frame_rate != 16000:
|
27 |
audio = audio.set_frame_rate(16000)
|
28 |
if audio.channels != 1:
|
29 |
audio = audio.set_channels(1)
|
30 |
file = file.split(".")[0]+".wav"
|
31 |
+
audio.export(file_name.split(".")[0]+".wav",format="wav")
|
32 |
except Exception as e:
|
33 |
print(e)
|
34 |
transcription= asr_model.transcribe([file])
|