Spaces:
Running
on
A10G
Running
on
A10G
add option to record from mic (#87)
Browse files
app.py
CHANGED
@@ -140,7 +140,12 @@ def predict_full(model, text, melody, duration, topk, topp, temperature, cfg_coe
|
|
140 |
top_k=topk, top_p=topp, temperature=temperature, cfg_coef=cfg_coef)
|
141 |
return outs[0]
|
142 |
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
144 |
def ui_full(launch_kwargs):
|
145 |
with gr.Blocks() as interface:
|
146 |
gr.Markdown(
|
@@ -154,7 +159,9 @@ def ui_full(launch_kwargs):
|
|
154 |
with gr.Column():
|
155 |
with gr.Row():
|
156 |
text = gr.Text(label="Input Text", interactive=True)
|
157 |
-
|
|
|
|
|
158 |
with gr.Row():
|
159 |
submit = gr.Button("Submit")
|
160 |
# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
|
@@ -171,6 +178,7 @@ def ui_full(launch_kwargs):
|
|
171 |
with gr.Column():
|
172 |
output = gr.Video(label="Generated Music")
|
173 |
submit.click(predict_full, inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef], outputs=[output])
|
|
|
174 |
gr.Examples(
|
175 |
fn=predict_full,
|
176 |
examples=[
|
@@ -252,12 +260,15 @@ def ui_batched(launch_kwargs):
|
|
252 |
with gr.Column():
|
253 |
with gr.Row():
|
254 |
text = gr.Text(label="Describe your music", lines=2, interactive=True)
|
255 |
-
|
|
|
|
|
256 |
with gr.Row():
|
257 |
submit = gr.Button("Generate")
|
258 |
with gr.Column():
|
259 |
output = gr.Video(label="Generated Music")
|
260 |
submit.click(predict_batched, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE)
|
|
|
261 |
gr.Examples(
|
262 |
fn=predict_batched,
|
263 |
examples=[
|
|
|
140 |
top_k=topk, top_p=topp, temperature=temperature, cfg_coef=cfg_coef)
|
141 |
return outs[0]
|
142 |
|
143 |
+
def toggle_audio_src(choice):
|
144 |
+
if choice == "mic":
|
145 |
+
return gr.update(source="microphone", value=None, label="Microphone")
|
146 |
+
else:
|
147 |
+
return gr.update(source="upload", value=None, label="File")
|
148 |
+
|
149 |
def ui_full(launch_kwargs):
|
150 |
with gr.Blocks() as interface:
|
151 |
gr.Markdown(
|
|
|
159 |
with gr.Column():
|
160 |
with gr.Row():
|
161 |
text = gr.Text(label="Input Text", interactive=True)
|
162 |
+
with gr.Column():
|
163 |
+
radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
|
164 |
+
melody = gr.Audio(source="upload", type="numpy", label="File", interactive=True, elem_id="melody-input")
|
165 |
with gr.Row():
|
166 |
submit = gr.Button("Submit")
|
167 |
# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.
|
|
|
178 |
with gr.Column():
|
179 |
output = gr.Video(label="Generated Music")
|
180 |
submit.click(predict_full, inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef], outputs=[output])
|
181 |
+
radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
|
182 |
gr.Examples(
|
183 |
fn=predict_full,
|
184 |
examples=[
|
|
|
260 |
with gr.Column():
|
261 |
with gr.Row():
|
262 |
text = gr.Text(label="Describe your music", lines=2, interactive=True)
|
263 |
+
with gr.Column():
|
264 |
+
radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")
|
265 |
+
melody = gr.Audio(source="upload", type="numpy", label="File", interactive=True, elem_id="melody-input")
|
266 |
with gr.Row():
|
267 |
submit = gr.Button("Generate")
|
268 |
with gr.Column():
|
269 |
output = gr.Video(label="Generated Music")
|
270 |
submit.click(predict_batched, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE)
|
271 |
+
radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)
|
272 |
gr.Examples(
|
273 |
fn=predict_batched,
|
274 |
examples=[
|