Update app.py to add more customizable features
Browse filesAdded Seed, Guidance Scale, Inference Steps, and Neg Prompt Fields
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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()
|