Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -32,9 +32,9 @@ class InferRunner:
|
|
32 |
).eval().to(device)
|
33 |
self.scheduler = DDPMScheduler.from_pretrained(train_args.scheduler_name, subfolder="scheduler")
|
34 |
|
35 |
-
def infer(caption, runner):
|
36 |
with torch.no_grad():
|
37 |
-
latents = runner.picomodel.demo_inference(caption, runner.scheduler, num_steps=
|
38 |
mel = runner.vae.decode_first_stage(latents)
|
39 |
wave = runner.vae.decode_to_waveform(mel)[0][:audio_len]
|
40 |
sf.write(f"synthesized/{caption}.wav", wave, samplerate=16000, subtype='PCM_16')
|
@@ -50,7 +50,7 @@ with gr.Blocks() as demo:
|
|
50 |
with gr.Row():
|
51 |
with gr.Column():
|
52 |
prompt = gr.Textbox(label="Prompt: Input your caption formatted as 'event1 at onset1-offset1_onset2-offset2 and event2 at onset1-offset1.",
|
53 |
-
value="spraying at 0.38-1.176_3.06-3.856 and gunshot at 1.729-3.729_4.367-6.367_7.031-9.031.")
|
54 |
run_button = gr.Button()
|
55 |
|
56 |
with gr.Accordion("Advanced options", open=False):
|
@@ -64,7 +64,7 @@ with gr.Blocks() as demo:
|
|
64 |
outaudio = gr.Audio()
|
65 |
|
66 |
run_button.click(fn=infer, inputs=[
|
67 |
-
prompt, num_steps, guidance], outputs=[outaudio])
|
68 |
# with gr.Row():
|
69 |
# with gr.Column():
|
70 |
# gr.Examples(
|
|
|
32 |
).eval().to(device)
|
33 |
self.scheduler = DDPMScheduler.from_pretrained(train_args.scheduler_name, subfolder="scheduler")
|
34 |
|
35 |
+
def infer(caption, runner, num_steps=200, guidance=3.0):
|
36 |
with torch.no_grad():
|
37 |
+
latents = runner.picomodel.demo_inference(caption, runner.scheduler, num_steps=num_steps, guidance=guidance, num_samples=1, audio_len=16000*10, disable_progress=True)
|
38 |
mel = runner.vae.decode_first_stage(latents)
|
39 |
wave = runner.vae.decode_to_waveform(mel)[0][:audio_len]
|
40 |
sf.write(f"synthesized/{caption}.wav", wave, samplerate=16000, subtype='PCM_16')
|
|
|
50 |
with gr.Row():
|
51 |
with gr.Column():
|
52 |
prompt = gr.Textbox(label="Prompt: Input your caption formatted as 'event1 at onset1-offset1_onset2-offset2 and event2 at onset1-offset1.",
|
53 |
+
value="spraying at 0.38-1.176_3.06-3.856 and gunshot at 1.729-3.729_4.367-6.367_7.031-9.031.",)
|
54 |
run_button = gr.Button()
|
55 |
|
56 |
with gr.Accordion("Advanced options", open=False):
|
|
|
64 |
outaudio = gr.Audio()
|
65 |
|
66 |
run_button.click(fn=infer, inputs=[
|
67 |
+
prompt, infer_runner, num_steps, guidance], outputs=[outaudio])
|
68 |
# with gr.Row():
|
69 |
# with gr.Column():
|
70 |
# gr.Examples(
|