Bils commited on
Commit
b25459f
·
verified ·
1 Parent(s): 66b1260

Update app.py

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