Update app.py
Browse files
app.py
CHANGED
@@ -73,14 +73,10 @@ print("----------> Loaded models <-----------")
|
|
73 |
|
74 |
gpu_timeout = int(os.getenv("GPU_TIMEOUT", 60))
|
75 |
@spaces.GPU(duration=gpu_timeout)
|
76 |
-
def generator(
|
77 |
history = history or ""
|
78 |
|
79 |
-
|
80 |
-
path = microphone
|
81 |
-
elif file_upload:
|
82 |
-
path = file_upload
|
83 |
-
|
84 |
waveform, sampling_rate = librosa.load(path, sr=SAMPLE_RATE, mono=True, duration=max_duration)
|
85 |
|
86 |
print(waveform.shape, sampling_rate)
|
@@ -132,23 +128,45 @@ def generator(microphone, file_upload, num_speakers, max_duration, history):
|
|
132 |
yield history, history, file_name
|
133 |
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
demo = gr.Interface(
|
136 |
-
generator,
|
137 |
-
inputs=
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
outputs=['text', 'state', 'file'],
|
145 |
-
title="Mongolian Whisper π²π³",
|
146 |
-
description=(
|
147 |
-
"Transcribe Microphone / Uploaded File in Mongolian Whisper Model."
|
148 |
),
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
)
|
151 |
|
|
|
152 |
# define queue - required for generators
|
153 |
demo.queue()
|
154 |
|
|
|
73 |
|
74 |
gpu_timeout = int(os.getenv("GPU_TIMEOUT", 60))
|
75 |
@spaces.GPU(duration=gpu_timeout)
|
76 |
+
def generator(file_upload, num_speakers, max_duration, history):
|
77 |
history = history or ""
|
78 |
|
79 |
+
path = file_upload
|
|
|
|
|
|
|
|
|
80 |
waveform, sampling_rate = librosa.load(path, sr=SAMPLE_RATE, mono=True, duration=max_duration)
|
81 |
|
82 |
print(waveform.shape, sampling_rate)
|
|
|
128 |
yield history, history, file_name
|
129 |
|
130 |
|
131 |
+
# demo = gr.Interface(
|
132 |
+
# generator,
|
133 |
+
# inputs=[
|
134 |
+
# gr.Audio(type="filepath"),
|
135 |
+
# gr.Number(value=1, label="Number of Speakers"),
|
136 |
+
# gr.Number(value=120, label="Maximum Duration (Seconds)"),
|
137 |
+
# 'state',
|
138 |
+
# ],
|
139 |
+
# outputs=['text', 'state', 'file'],
|
140 |
+
# title="Mongolian Whisper π²π³",
|
141 |
+
# description=(
|
142 |
+
# "Transcribe Microphone / Uploaded File in Mongolian Whisper Model."
|
143 |
+
# )
|
144 |
+
# )
|
145 |
+
|
146 |
+
import gradio as gr
|
147 |
+
|
148 |
demo = gr.Interface(
|
149 |
+
fn=generator,
|
150 |
+
inputs=gr.Column( # π wrap inputs in a Column
|
151 |
+
[
|
152 |
+
gr.Audio(type="filepath"),
|
153 |
+
gr.Number(value=1, label="Number of Speakers within Audio."),
|
154 |
+
gr.Number(value=120, label="Maximum Duration (Seconds)"),
|
155 |
+
gr.State(), # 'state' should be a gr.State component, not a plain string
|
156 |
+
]
|
|
|
|
|
|
|
|
|
157 |
),
|
158 |
+
outputs=gr.Column( # π wrap outputs in a Column
|
159 |
+
[
|
160 |
+
gr.Textbox(label="Transcription"),
|
161 |
+
gr.State(),
|
162 |
+
gr.File(label="Output File"),
|
163 |
+
]
|
164 |
+
),
|
165 |
+
title="Mongolian Whisper π²π³",
|
166 |
+
description="Transcribe Microphone / Uploaded File in Mongolian Whisper Model."
|
167 |
)
|
168 |
|
169 |
+
|
170 |
# define queue - required for generators
|
171 |
demo.queue()
|
172 |
|