Bils commited on
Commit
b511f54
·
verified ·
1 Parent(s): 8c25665

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -62
app.py CHANGED
@@ -131,71 +131,74 @@ def blend_audio(voice_path: str, music_path: str, ducking: bool):
131
  # ---------------------------------------------------------------------
132
  with gr.Blocks() as demo:
133
  gr.Markdown("""
134
- # 🎧 AI Promo Studio🚀
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
 
200
  gr.Markdown("""
201
  <hr>
 
131
  # ---------------------------------------------------------------------
132
  with gr.Blocks() as demo:
133
  gr.Markdown("""
134
+ # 🎧 AI Promo Studio 🚀
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
+ # Ensure the .click is inside this Blocks context
152
+ generate_script_button.click(
153
+ fn=lambda user_prompt, model_id, duration: generate_script(user_prompt, model_id, hf_token, duration),
154
+ inputs=[user_prompt, llama_model_id, duration],
155
+ outputs=[script_output, sound_design_output, music_suggestion_output],
156
+ )
157
+
158
+ # Step 2: Generate Voice
159
+ with gr.Tab("Step 2: Generate Voice"):
160
+ with gr.Row():
161
+ speaker = gr.Textbox(label="Voice Style (optional)", placeholder="E.g., male, female, or neutral.")
162
+
163
+ generate_voice_button = gr.Button("Generate Voice")
164
+ voice_output = gr.Audio(label="Generated Voice", type="filepath")
165
+
166
+ # Ensure the .click is inside this Blocks context
167
+ generate_voice_button.click(
168
+ fn=generate_voice,
169
+ inputs=[script_output, speaker],
170
+ outputs=[voice_output],
171
+ )
172
+
173
+ # Step 3: Generate Music
174
+ with gr.Tab("Step 3: Generate Music"):
175
+ with gr.Row():
176
+ audio_length = gr.Slider(label="Music Length (tokens)", minimum=128, maximum=1024, step=64, value=512)
177
+
178
+ generate_music_button = gr.Button("Generate Music")
179
+ music_output = gr.Audio(label="Generated Music", type="filepath")
180
+
181
+ # Ensure the .click is inside this Blocks context
182
+ generate_music_button.click(
183
+ fn=generate_music,
184
+ inputs=[music_suggestion_output, audio_length],
185
+ outputs=[music_output],
186
+ )
187
+
188
+ # Step 4: Blend Audio
189
+ with gr.Tab("Step 4: Blend Audio"):
190
+ with gr.Row():
191
+ ducking = gr.Checkbox(label="Enable Ducking", value=True)
192
+
193
+ blend_button = gr.Button("Blend Audio")
194
+ final_output = gr.Audio(label="Final Promo Audio", type="filepath")
195
+
196
+ # Ensure the .click is inside this Blocks context
197
+ blend_button.click(
198
+ fn=blend_audio,
199
+ inputs=[voice_output, music_output, ducking],
200
+ outputs=[final_output],
201
+ )
202
 
203
  gr.Markdown("""
204
  <hr>