Bils commited on
Commit
35e8eba
·
verified ·
1 Parent(s): b25459f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -58
app.py CHANGED
@@ -125,63 +125,66 @@ with gr.Blocks() as demo:
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>
@@ -190,4 +193,4 @@ with gr.Tabs():
190
  </p>
191
  """)
192
 
193
- demo.launch(debug=True)
 
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
+ generate_music_button.click(
170
+ fn=lambda music_suggestion, audio_length: generate_music(music_suggestion, audio_length),
171
+ inputs=[music_suggestion_output, audio_length],
172
+ outputs=[music_output],
173
+ )
174
+
175
+ # Step 4: Blend Audio
176
+ with gr.Tab("Step 4: Blend Audio"):
177
+ with gr.Row():
178
+ ducking = gr.Checkbox(label="Enable Ducking", value=True)
179
+
180
+ blend_button = gr.Button("Blend Audio")
181
+ final_output = gr.Audio(label="Final Promo Audio", type="filepath")
182
+
183
+ blend_button.click(
184
+ fn=blend_audio,
185
+ inputs=[voice_output, music_output, ducking],
186
+ outputs=[final_output],
187
+ )
188
 
189
  gr.Markdown("""
190
  <hr>
 
193
  </p>
194
  """)
195
 
196
+ demo.launch(debug=True)