add option to record from mic (#87)
Browse files139 unmodified lines1401411421431441451467 unmodified lines15415515615715815916010 unmodified lines17117217317417517675 unmodified lines252253254255256257258259260261262263139 unmodified linestop_k=topk, top_p=topp, temperature=temperature, cfg_coef=cfg_coef)return outs[0]def ui_full(launch_kwargs):with gr.Blocks() as interface:gr.Markdown(7 unmodified lineswith gr.Column():with gr.Row():text = gr.Text(label="Input Text", interactive=True)melody = gr.Audio(source="upload", type="numpy", label="Melody Condition (optional)", interactive=True)with gr.Row():submit = gr.Button("Submit")# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.10 unmodified lineswith gr.Column():output = gr.Video(label="Generated Music")submit.click(predict_full, inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef], outputs=[output])gr.Examples(fn=predict_full,examples=[75 unmodified lineswith gr.Column():with gr.Row():text = gr.Text(label="Describe your music", lines=2, interactive=True)melody = gr.Audio(source="upload", type="numpy", label="Condition on a melody (optional)", interactive=True)with gr.Row():submit = gr.Button("Generate")with gr.Column():output = gr.Video(label="Generated Music")submit.click(predict_batched, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE)gr.Examples(fn=predict_batched,examples=[139 unmodified lines1401411421431441451461471481491501517 unmodified lines15916016116216316416516616710 unmodified lines17817918018118218318475 unmodified lines260261262263264265266267268269270271272273274139 unmodified linestop_k=topk, top_p=topp, temperature=temperature, cfg_coef=cfg_coef)return outs[0]def toggle_audio_src(choice):if choice == "mic":return gr.update(source="microphone", value=None, label="Microphone")else:return gr.update(source="upload", value=None, label="File")def ui_full(launch_kwargs):with gr.Blocks() as interface:gr.Markdown(7 unmodified lineswith gr.Column():with gr.Row():text = gr.Text(label="Input Text", interactive=True)with gr.Column():radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")melody = gr.Audio(source="upload", type="numpy", label="File", interactive=True, elem_id="melody-input")with gr.Row():submit = gr.Button("Submit")# Adapted from https://github.com/rkfg/audiocraft/blob/long/app.py, MIT license.10 unmodified lineswith gr.Column():output = gr.Video(label="Generated Music")submit.click(predict_full, inputs=[model, text, melody, duration, topk, topp, temperature, cfg_coef], outputs=[output])radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)gr.Examples(fn=predict_full,examples=[75 unmodified lineswith gr.Column():with gr.Row():text = gr.Text(label="Describe your music", lines=2, interactive=True)with gr.Column():radio = gr.Radio(["file", "mic"], value="file", label="Condition on a melody (optional) File or Mic")melody = gr.Audio(source="upload", type="numpy", label="File", interactive=True, elem_id="melody-input")with gr.Row():submit = gr.Button("Generate")with gr.Column():output = gr.Video(label="Generated Music")submit.click(predict_batched, inputs=[text, melody], outputs=[output], batch=True, max_batch_size=MAX_BATCH_SIZE)radio.change(toggle_audio_src, radio, [melody], queue=False, show_progress=False)gr.Examples(fn=predict_batched,examples=[
app.py+14-3