Bils commited on
Commit
f16af7a
·
verified ·
1 Parent(s): 82c3969

Update app.py

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