Spaces:
Runtime error
Runtime error
himanshu1844
commited on
Commit
·
5b56f35
1
Parent(s):
f5a3c14
Add application file
Browse files
app.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
description_text = """
|
3 |
+
* Powered by **Stability AI**
|
4 |
+
Generate high quality and faithful audio in just a few seconds using <b>VOXIFY</b> by providing a text prompt. <b>VOXIFY</b> was trained from scratch and underwent alignment to follow human instructions using a new method called <b>CLAP-Ranked Preference Optimization (CRPO)</b>.
|
5 |
+
|
6 |
+
"""
|
7 |
+
# Gradio input and output components
|
8 |
+
input_text = gr.Textbox(lines=2, label="Prompt")
|
9 |
+
#output_format = gr.Radio(label = "Output format", info = "The file you can dowload", choices = "wav"], value = "wav")
|
10 |
+
output_audio = gr.Audio(label="Generated Audio", type="filepath")
|
11 |
+
denoising_steps = gr.Slider(minimum=10, maximum=100, value=25, step=5, label="Steps", interactive=True)
|
12 |
+
guidance_scale = gr.Slider(minimum=1, maximum=10, value=4.5, step=0.5, label="Guidance Scale", interactive=True)
|
13 |
+
duration_scale = gr.Slider(minimum=1, maximum=30, value=10, step=1, label="Duration", interactive=True)
|
14 |
+
|
15 |
+
def gradio_generate(prompt, steps, guidance,duration=10):
|
16 |
+
|
17 |
+
# output = tangoflux.generate(prompt,steps=steps,guidance_scale=guidance,duration=duration)
|
18 |
+
#output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
|
19 |
+
|
20 |
+
|
21 |
+
#wavio.write(output_filename, output_wave, rate=44100, sampwidth=2)
|
22 |
+
# filename = 'temp.wav'
|
23 |
+
#print(f"Saving audio to file: {unique_filename}")
|
24 |
+
|
25 |
+
# Save to file
|
26 |
+
# output = output[:,:int(duration*44100)]
|
27 |
+
# torchaudio.save(filename, output, 44100)
|
28 |
+
|
29 |
+
|
30 |
+
# Return the path to the generated audio file
|
31 |
+
return prompt
|
32 |
+
|
33 |
+
# Gradio interface
|
34 |
+
gr_interface = gr.Interface(
|
35 |
+
fn=gradio_generate,
|
36 |
+
inputs=[input_text, denoising_steps, guidance_scale,duration_scale],
|
37 |
+
outputs="text",
|
38 |
+
title="VOXIFY:GENERATE SOUND EFFECTS THROUGH TEXT",
|
39 |
+
description=description_text,
|
40 |
+
allow_flagging=None,
|
41 |
+
examples=[
|
42 |
+
["Generate the festive sounds of a fireworks show: explosions lighting up the sky, crowd cheering, and the faint music playing in the background!! Celebration of the new year!"],
|
43 |
+
["Melodic human whistling harmonizing with natural birdsong"],
|
44 |
+
["A parade marches through a town square, with drumbeats pounding, children clapping, and a horse neighing amidst the commotion"],
|
45 |
+
["Quiet speech and then and airplane flying away"],
|
46 |
+
["A soccer ball hits a goalpost with a metallic clang, followed by cheers, clapping, and the distant hum of a commentator’s voice"],
|
47 |
+
["A basketball bounces rhythmically on a court, shoes squeak against the floor, and a referee’s whistle cuts through the air"],
|
48 |
+
["Dripping water echoes sharply, a distant growl reverberates through the cavern, and soft scraping metal suggests something lurking unseen"],
|
49 |
+
["A cow is mooing whilst a lion is roaring in the background as a hunter shoots. A flock of birds subsequently fly away from the trees."],
|
50 |
+
["The deep growl of an alligator ripples through the swamp as reeds sway with a soft rustle and a turtle splashes into the murky water"],
|
51 |
+
["Gentle female voice cooing and baby responding with happy gurgles and giggles"],
|
52 |
+
['doorbell ding once followed by footsteps gradually getting louder and a door is opened '],
|
53 |
+
["A fork scrapes a plate, water drips slowly into a sink, and the faint hum of a refrigerator lingers in the background"],
|
54 |
+
["Powerful ocean waves crashing and receding on sandy beach with distant seagulls"],
|
55 |
+
["Emulate the lively sounds of a retro arcade: 8-bit game music, coins clinking. People cheering occasionally when players winning"],
|
56 |
+
["Simulate a forest ambiance with birds chirping and wind rustling through the leaves"],
|
57 |
+
["A train conductor blows a sharp whistle, metal wheels screech on the rails, and passengers murmur while settling into their seats"],
|
58 |
+
["Generate an energetic and bustling city street scene with distant traffic and close conversations"],
|
59 |
+
["Alarms blare with rising urgency as fragments clatter against a metallic hull, interrupted by a faint hiss of escaping air"],
|
60 |
+
["Create a serene soundscape of a quiet beach at sunset"],
|
61 |
+
["Tiny pops and hisses of chemical reactions intermingle with the rhythmic pumping of a centrifuge and the soft whirr of air filtration"],
|
62 |
+
["A train conductor blows a sharp whistle, metal wheels screech on the rails, and passengers murmur while settling into their seats"],
|
63 |
+
["Emulate the lively sounds of a retro arcade: 8-bit game music, coins clinking. People cheering occasionally when players winning"],
|
64 |
+
["Quiet whispered conversation gradually fading into distant jet engine roar diminishing into silence"],
|
65 |
+
["Clear sound of bicycle tires crunching on loose gravel and dirt, followed by deep male laughter echoing"],
|
66 |
+
["Multiple ducks quacking loudly with splashing water and piercing wild animal shriek in background"],
|
67 |
+
["Create the underwater soundscape: gentle waves, faint whale calls, and the occasional clink of scuba gear"],
|
68 |
+
["Recreate the sounds of an active volcano: rumbling earth, lava bubbling, and the occasional loud explosive roar of an eruption"],
|
69 |
+
["A pile of coins spills onto a wooden table with a metallic clatter, followed by the hushed murmur of a tavern crowd and the creak of a swinging door"],
|
70 |
+
["Clear male voice speaking, sharp popping sound, followed by genuine group laughter"],
|
71 |
+
["Stream of water hitting empty ceramic cup, pitch rising as cup fills up"],
|
72 |
+
["Massive crowd erupting in thunderous applause and excited cheering"],
|
73 |
+
["Deep rolling thunder with bright lightning strikes crackling through sky"],
|
74 |
+
["Aggressive dog barking and distressed cat meowing as racing car roars past at high speed"],
|
75 |
+
["Peaceful stream bubbling and birds singing, interrupted by sudden explosive gunshot"],
|
76 |
+
["Man speaking outdoors, goat bleating loudly, metal gate scraping closed, ducks quacking frantically, wind howling into microphone"],
|
77 |
+
["Series of loud aggressive dog barks echoing"],
|
78 |
+
["Multiple distinct cat meows at different pitches"],
|
79 |
+
["Rhythmic wooden table tapping overlaid with steady water pouring sound"],
|
80 |
+
["Sustained crowd applause with camera clicks and amplified male announcer voice"],
|
81 |
+
["Two sharp gunshots followed by panicked birds taking flight with rapid wing flaps"],
|
82 |
+
["Deep rhythmic snoring with clear breathing patterns"],
|
83 |
+
["Multiple racing engines revving and accelerating with sharp whistle piercing through"],
|
84 |
+
["Massive stadium crowd cheering as thunder crashes and lightning strikes"],
|
85 |
+
["Heavy helicopter blades chopping through air with engine and wind noise"],
|
86 |
+
["Dog barking excitedly and man shouting as race car engine roars past"],
|
87 |
+
["A bicycle peddling on dirt and gravel followed by a man speaking then laughing"],
|
88 |
+
["Ducks quack and water splashes with some animal screeching in the background"],
|
89 |
+
["Describe the sound of the ocean"],
|
90 |
+
["A woman and a baby are having a conversation"],
|
91 |
+
["A man speaks followed by a popping noise and laughter"],
|
92 |
+
["A cup is filled from a faucet"],
|
93 |
+
["An audience cheering and clapping"],
|
94 |
+
["Rolling thunder with lightning strikes"],
|
95 |
+
["A dog barking and a cat mewing and a racing car passes by"],
|
96 |
+
["Gentle water stream, birds chirping and sudden gun shot"],
|
97 |
+
["A dog barking"],
|
98 |
+
["A cat meowing"],
|
99 |
+
["Wooden table tapping sound while water pouring"],
|
100 |
+
["Applause from a crowd with distant clicking and a man speaking over a loudspeaker"],
|
101 |
+
["two gunshots followed by birds flying away while chirping"],
|
102 |
+
["Whistling with birds chirping"],
|
103 |
+
["A person snoring"],
|
104 |
+
["Motor vehicles are driving with loud engines and a person whistles"],
|
105 |
+
["People cheering in a stadium while thunder and lightning strikes"],
|
106 |
+
["A helicopter is in flight"],
|
107 |
+
["A dog barking and a man talking and a racing car passes by"],
|
108 |
+
],
|
109 |
+
cache_examples="lazy", # Turn on to cache.
|
110 |
+
)
|
111 |
+
|
112 |
+
|
113 |
+
|
114 |
+
gr_interface.launch()
|