Bils commited on
Commit
af47e63
·
verified ·
1 Parent(s): 2547eea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -55
app.py CHANGED
@@ -135,62 +135,66 @@ with gr.Blocks() as demo:
135
  Generate and mix radio promos effortlessly with AI tools!
136
  """)
137
 
 
 
138
  with gr.Tab("Step 1: Generate Script"):
139
- with gr.Row():
140
- user_prompt = gr.Textbox(label="Promo Idea", placeholder="E.g., A 30-second promo for a morning show.")
141
- llama_model_id = gr.Textbox(label="Llama Model ID", value="meta-llama/Meta-Llama-3-8B-Instruct")
142
- duration = gr.Slider(label="Duration (seconds)", minimum=15, maximum=60, step=15, value=30)
143
-
144
- generate_script_button = gr.Button("Generate Script")
145
- script_output = gr.Textbox(label="Generated Script", lines=5)
146
- sound_design_output = gr.Textbox(label="Sound Design", lines=3)
147
- music_suggestion_output = gr.Textbox(label="Music Suggestions", lines=3)
148
-
149
- generate_script_button.click(
150
- fn=lambda user_prompt, model_id, duration: generate_script(user_prompt, model_id, hf_token, duration),
151
- inputs=[user_prompt, llama_model_id, duration], # Gradio components only
152
- outputs=[script_output, sound_design_output, music_suggestion_output],
153
- )
154
-
155
-
156
- with gr.Tab("Step 2: Generate Voice"):
157
- with gr.Row():
158
- speaker = gr.Textbox(label="Voice Style (optional)", placeholder="E.g., male, female, or neutral.")
159
-
160
- generate_voice_button = gr.Button("Generate Voice")
161
- voice_output = gr.Audio(label="Generated Voice", type="filepath")
162
-
163
- generate_voice_button.click(
164
- fn=generate_voice,
165
- inputs=[script_output, speaker],
166
- outputs=[voice_output],
167
- )
168
-
169
- with gr.Tab("Step 3: Generate Music"):
170
- with gr.Row():
171
- audio_length = gr.Slider(label="Music Length (tokens)", minimum=128, maximum=1024, step=64, value=512)
172
-
173
- generate_music_button = gr.Button("Generate Music")
174
- music_output = gr.Audio(label="Generated Music", type="filepath")
175
-
176
- generate_music_button.click(
177
- fn=generate_music,
178
- inputs=[music_suggestion_output, audio_length],
179
- outputs=[music_output],
180
- )
181
-
182
- with gr.Tab("Step 4: Blend Audio"):
183
- with gr.Row():
184
- ducking = gr.Checkbox(label="Enable Ducking", value=True)
185
-
186
- blend_button = gr.Button("Blend Audio")
187
- final_output = gr.Audio(label="Final Promo Audio", type="filepath")
188
-
189
- blend_button.click(
190
- fn=blend_audio,
191
- inputs=[voice_output, music_output, ducking],
192
- outputs=[final_output],
193
- )
 
 
194
 
195
  gr.Markdown("""
196
  <hr>
 
135
  Generate and mix radio promos effortlessly with AI tools!
136
  """)
137
 
138
+ with gr.Tabs():
139
+ # Step 1: Generate Script
140
  with gr.Tab("Step 1: Generate Script"):
141
+ with gr.Row():
142
+ user_prompt = gr.Textbox(label="Promo Idea", placeholder="E.g., A 30-second promo for a morning show.")
143
+ llama_model_id = gr.Textbox(label="Llama Model ID", value="meta-llama/Meta-Llama-3-8B-Instruct")
144
+ duration = gr.Slider(label="Duration (seconds)", minimum=15, maximum=60, step=15, value=30)
145
+
146
+ generate_script_button = gr.Button("Generate Script")
147
+ script_output = gr.Textbox(label="Generated Script", lines=5)
148
+ sound_design_output = gr.Textbox(label="Sound Design", lines=3)
149
+ music_suggestion_output = gr.Textbox(label="Music Suggestions", lines=3)
150
+
151
+ generate_script_button.click(
152
+ fn=lambda user_prompt, model_id, duration: generate_script(user_prompt, model_id, hf_token, duration),
153
+ inputs=[user_prompt, llama_model_id, duration],
154
+ outputs=[script_output, sound_design_output, music_suggestion_output],
155
+ )
156
+
157
+ # Step 2: Generate Voice
158
+ with gr.Tab("Step 2: Generate Voice"):
159
+ with gr.Row():
160
+ speaker = gr.Textbox(label="Voice Style (optional)", placeholder="E.g., male, female, or neutral.")
161
+
162
+ generate_voice_button = gr.Button("Generate Voice")
163
+ voice_output = gr.Audio(label="Generated Voice", type="filepath")
164
+
165
+ generate_voice_button.click(
166
+ fn=generate_voice,
167
+ inputs=[script_output, speaker],
168
+ outputs=[voice_output],
169
+ )
170
+
171
+ # Step 3: Generate Music
172
+ with gr.Tab("Step 3: Generate Music"):
173
+ with gr.Row():
174
+ audio_length = gr.Slider(label="Music Length (tokens)", minimum=128, maximum=1024, step=64, value=512)
175
+
176
+ generate_music_button = gr.Button("Generate Music")
177
+ music_output = gr.Audio(label="Generated Music", type="filepath")
178
+
179
+ generate_music_button.click(
180
+ fn=generate_music,
181
+ inputs=[music_suggestion_output, audio_length],
182
+ outputs=[music_output],
183
+ )
184
+
185
+ # Step 4: Blend Audio
186
+ with gr.Tab("Step 4: Blend Audio"):
187
+ with gr.Row():
188
+ ducking = gr.Checkbox(label="Enable Ducking", value=True)
189
+
190
+ blend_button = gr.Button("Blend Audio")
191
+ final_output = gr.Audio(label="Final Promo Audio", type="filepath")
192
+
193
+ blend_button.click(
194
+ fn=blend_audio,
195
+ inputs=[voice_output, music_output, ducking],
196
+ outputs=[final_output],
197
+ )
198
 
199
  gr.Markdown("""
200
  <hr>