spdraptor commited on
Commit
30a9e85
·
verified ·
1 Parent(s): cfd828f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -55
app.py CHANGED
@@ -82,61 +82,31 @@ def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
82
  # Return the path to the generated audio file
83
  return unique_filename
84
 
85
- # Setting up the Gradio Interface
86
- interface = gr.Interface(
87
- fn=generate_audio,
88
- inputs=[
89
- gr.Textbox(label="Prompt", placeholder="Enter your text prompt here"),
90
- gr.Slider(0, 47, value=30, label="Duration in Seconds"),
91
- gr.Slider(10, 150, value=100, step=10, label="Number of Diffusion Steps"),
92
- gr.Slider(1, 15, value=7, step=0.1, label="CFG Scale")
93
- ],
94
- outputs=gr.Audio(type="filepath", label="Generated Audio"),
95
- title="Stable Audio Generator",
96
- description="Generate variable-length stereo audio at 44.1kHz from text prompts using Stable Audio Open 1.0.",
97
- examples=[
98
- [
99
- "Create a serene soundscape of a quiet beach at sunset.", # Text prompt
100
-
101
- 45, # Duration in Seconds
102
- 100, # Number of Diffusion Steps
103
- 10, # CFG Scale
104
- ],
105
- [
106
- "Generate an energetic and bustling city street scene with distant traffic and close conversations.", # Text prompt
107
-
108
- 30, # Duration in Seconds
109
- 120, # Number of Diffusion Steps
110
- 5, # CFG Scale
111
- ],
112
- [
113
- "Simulate a forest ambiance with birds chirping and wind rustling through the leaves.", # Text prompt
114
- 60, # Duration in Seconds
115
- 140, # Number of Diffusion Steps
116
- 7.5, # CFG Scale
117
- ],
118
- [
119
- "Recreate a gentle rainfall with distant thunder.", # Text prompt
120
-
121
- 35, # Duration in Seconds
122
- 110, # Number of Diffusion Steps
123
- 8, # CFG Scale
124
-
125
- ],
126
- [
127
- "Imagine a jazz cafe environment with soft music and ambient chatter.", # Text prompt
128
- 25, # Duration in Seconds
129
- 90, # Number of Diffusion Steps
130
- 6, # CFG Scale
131
-
132
- ],
133
- ["Rock beat played in a treated studio, session drumming on an acoustic kit.",
134
- 30, # Duration in Seconds
135
- 100, # Number of Diffusion Steps
136
- 7, # CFG Scale
137
-
138
- ]
139
- ])
140
 
141
 
142
  # Pre-load the model to avoid multiprocessing issues
 
82
  # Return the path to the generated audio file
83
  return unique_filename
84
 
85
+
86
+ DESCRIPTION = "Welcome to Raptor APIs"
87
+
88
+
89
+ css = """
90
+ #output {
91
+ height: 500px;
92
+ overflow: auto;
93
+ border: 1px solid #ccc;
94
+ }
95
+ """
96
+
97
+ with gr.Blocks(css=css) as demo:
98
+ gr.Markdown(DESCRIPTION)
99
+ with gr.Tab(label="GenAudio"):
100
+ with gr.Row():
101
+ with gr.Column
102
+ prompt = gr.Textbox(label="Prompt", placeholder="Enter your text prompt here"),
103
+ duration = gr.Slider(0, 47, value=30, label="Duration in Seconds"),
104
+ steps = gr.Slider(10, 150, value=100, step=10, label="Number of Diffusion Steps"),
105
+ cfg = gr.Slider(1, 15, value=7, step=0.1, label="CFG Scale"),
106
+
107
+ mask_btn.click(generate_audio,input=[prompt,duration, steps, cfg],output=output,api_name="genAudio")
108
+ with gr.Column():
109
+ output = gr.Image(label="audio")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
 
112
  # Pre-load the model to avoid multiprocessing issues