jytole commited on
Commit
876cdf7
1 Parent(s): a642956

Update app.py to add more customizable features

Browse files

Added Seed, Guidance Scale, Inference Steps, and Neg Prompt Fields

Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -9,13 +9,23 @@ pipe = AudioLDMPipeline.from_pretrained(repo_id, torch_dtype=torch.float32)
9
  pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
10
  pipe = pipe.to("cpu")
11
 
12
- def texttoaudio(prompt):
13
- audio = pipe(prompt, num_inference_steps=10, audio_length_in_s=5.0).audios[0]
 
 
 
 
 
 
 
 
 
 
14
 
15
  # save the audio sample as a .wav file
16
  # scipy.io.wavfile.write("output.wav", rate=16000, data=audio)
17
  return (16000, audio)
18
 
19
- iface = gr.Interface(fn=texttoaudio, inputs="text", outputs="audio")
20
 
21
  iface.launch()
 
9
  pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
10
  pipe = pipe.to("cpu")
11
 
12
+ def texttoaudio(prompt, neg_prompt, seed, inf_steps, guidance_scale):
13
+ if prompt is None:
14
+ raise gr.Error("Please provide a text input.")
15
+
16
+ audio = pipe(
17
+ prompt,
18
+ neg_prompt=neg_prompt,
19
+ num_inference_steps=inf_steps,
20
+ guidance_scale=guidance_scale
21
+ audio_length_in_s=5.0,
22
+ generator=generator.manual_seed(int(seed)),
23
+ ).audios[0]
24
 
25
  # save the audio sample as a .wav file
26
  # scipy.io.wavfile.write("output.wav", rate=16000, data=audio)
27
  return (16000, audio)
28
 
29
+ iface = gr.Interface(fn=texttoaudio, title="Prompt, Neg Prompt, Seed, Inf Steps, Guidance Scale", inputs=["text", "text", "number", "number", "number"], outputs="audio")
30
 
31
  iface.launch()