ajayarora1235
commited on
Commit
•
f362ef8
1
Parent(s):
4162802
fixed up button issues
Browse files
app.py
CHANGED
@@ -79,164 +79,7 @@ with gr.Blocks(css=css) as demo:
|
|
79 |
|
80 |
def change_tab(id):
|
81 |
return gr.Tabs(selected=id)
|
82 |
-
continue_btn.click(change_tab, gr.Number(1, visible=False), tabs)
|
83 |
-
|
84 |
-
# with gr.TabItem("Tutorial", id=1):
|
85 |
-
# gr.Markdown("""<center><font size=4>Now, let's walkthrough writing a verse together! Start chatting with the chatbot.</font></center>""")
|
86 |
-
|
87 |
-
# character = gr.State(value="A 18-year old boy who dreams of being a pop star that uplifts people going through the difficulties of life")
|
88 |
-
|
89 |
-
# starting_messages, starting_history = get_starting_messages("", "Home", "Missing home", "Ballad", instrumental_textbox.value)
|
90 |
-
|
91 |
-
# messages = gr.State(value=starting_messages)
|
92 |
-
|
93 |
-
# section_meanings = gr.State(value="")
|
94 |
-
# approve_button.click(update_song_details, inputs=[instrumental_output], outputs=[genre_input, title_input, blurb_input]).then(get_sections, inputs=[blurb_input, instrumental_output], outputs=[section_meanings])
|
95 |
-
|
96 |
-
# # lyrics_display = gr.State("")
|
97 |
-
|
98 |
-
# generated_audios = gr.State([])
|
99 |
-
# def reset_textbox(textbox):
|
100 |
-
# return ""
|
101 |
-
|
102 |
-
# character = gr.State(value="A 18-year old boy who dreams of being a pop star that uplifts people going through the difficulties of life")
|
103 |
-
|
104 |
-
# starting_messages, starting_history = get_starting_messages("", "Home", "Missing home", "Ballad", instrumental_textbox.value)
|
105 |
-
# print(starting_history, "STARTING HISTORY")
|
106 |
-
# messages = gr.State(value=starting_messages)
|
107 |
-
# # messages += [{"role": "assistant", "content": "You are a songwriter. You write songs."}]
|
108 |
-
# # journal_messages = gr.State(value=[journal_starting_message])
|
109 |
-
# # journal_response = gr.State(value="")
|
110 |
-
|
111 |
-
# generated_audios = gr.State(value=[])
|
112 |
-
# tutorial_step = gr.Number(0, visible=False)
|
113 |
-
|
114 |
-
# with gr.Row():
|
115 |
-
# with gr.Column(scale=2):
|
116 |
-
# chatbot_history = gr.Chatbot(type="messages", value=starting_history, label='SongChat', placeholder=None, layout='bubble', bubble_full_width=False, height=500)
|
117 |
-
# with gr.Row():
|
118 |
-
# typical_responses = [textbox, submit]
|
119 |
-
|
120 |
-
# def update_response_options(buttons, button_dict):
|
121 |
-
# return [gr.Textbox(visible=len(buttons)==0, scale=4), gr.Button(visible=len(buttons)==0, scale=2)] + [gr.Button(visible=(x in buttons)) for x in button_dict.keys()]
|
122 |
-
|
123 |
-
# button_options = gr.State([])
|
124 |
-
# button_dict = gr.State({
|
125 |
-
# "revise lyrics": "Can we revise the lyrics?",
|
126 |
-
# "generate audio snippet": "Can you generate an audio snippet?",
|
127 |
-
# "continue revising" : "Can we continue revising this section?",
|
128 |
-
# "generate audio snippet with new lyrics": "Can you generate an audio snippet with these new lyrics?",
|
129 |
-
# "return to original instrumental": "Can you use the original clip for this section instead?",
|
130 |
-
# "revise genre": "Can we revise the instrumental tags?",
|
131 |
-
# "re-revise genre": "Can we revise the instrumental tags?",
|
132 |
-
# "continue to next section": "Looks good! Let's move on to the next section.",
|
133 |
-
# "merge snippets": "Can you merge this snippet into its full song?"
|
134 |
-
# })
|
135 |
-
|
136 |
-
# for button in button_dict.value.keys():
|
137 |
-
# btn = gr.Button(button, visible=(button in button_options.value))
|
138 |
-
# typical_responses.append(btn)
|
139 |
-
|
140 |
-
|
141 |
-
# with gr.Column(elem_id="audio-group", scale=1) as audio_group_column:
|
142 |
-
# # songwriter_creativity = gr.Slider(label="Songwriter LLM Temperature", minimum=0, maximum=1, step=0.01, value=1)
|
143 |
-
|
144 |
-
# with gr.Group():
|
145 |
-
# # loop thru all audio in audio_clips
|
146 |
-
# gr.Markdown("""<center><font size=4>All Generations</font></center>""")
|
147 |
-
|
148 |
-
# @gr.render(inputs=generated_audios, triggers=[demo.load, generated_audios.change, textbox.submit, submit.click] + [btn.click for btn in typical_responses[2:]])
|
149 |
-
# def render_audio_group(generated_audios):
|
150 |
-
# # audio_group = gr.Group()
|
151 |
-
# for audio in generated_audios:
|
152 |
-
# clip_path, lyrics, instrumental, title, status = audio
|
153 |
-
# with gr.Accordion(title, open=False):
|
154 |
-
# if status == 'complete':
|
155 |
-
# gr.Audio(value=clip_path, label=title, interactive=False, show_label=False, waveform_options={"show_controls": False})
|
156 |
-
# else:
|
157 |
-
# gr.HTML(f'<audio controls><source src="{clip_path}" type="audio/mp3"></audio>')
|
158 |
-
# gr.TextArea(label="Lyrics", value=lyrics, interactive=False, show_label=False)
|
159 |
-
# gr.TextArea(label="Instrumental", value=instrumental, interactive=False, show_label=False, max_lines=1)
|
160 |
-
|
161 |
-
# gr.Markdown("""<center><font size=4>Current Generation</font></center>""")
|
162 |
-
# current_section = gr.Textbox(label="Current section", value="Verse 1", interactive=False, show_label=True)
|
163 |
-
# current_lyrics = gr.Textbox(label="Lyrics", value="", interactive=True, show_label=True)
|
164 |
-
# with gr.Row():
|
165 |
-
# curr_tags = gr.Textbox(label="Instrumental Tags", value="", interactive=True, show_label=True)
|
166 |
-
# # @gr.render(inputs=generated_audios, triggers=[demo.load])
|
167 |
-
# # def render_clip_to_continue(generated_audios):
|
168 |
-
# audio_clips = [x[3] for x in generated_audios.value]
|
169 |
-
# clip_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=audio_clips+[""], interactive=True)
|
170 |
-
# #clip_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=audio_clips+[""], interactive=True)
|
171 |
-
# songwriter_style = gr.Dropdown(label='Songwriter Style', value= "GPT 4o", choices=["GPT 4o", "d4vd"], interactive=True)
|
172 |
-
# with gr.Row():
|
173 |
-
# #curr_audio = gr.State("")
|
174 |
-
# curr_audio = gr.HTML(label="Generated section")
|
175 |
-
# regen = gr.Button("Re-generate")
|
176 |
-
|
177 |
-
|
178 |
-
# section_meanings = gr.State(value="")
|
179 |
-
# approve_button.click(update_song_details, inputs=[instrumental_output], outputs=[genre_input, title_input, blurb_input]).then(get_sections, inputs=[blurb_input, instrumental_output], outputs=[section_meanings])
|
180 |
-
# continue_btn.click(get_starting_messages, inputs=[instrumental_textbox, title_input, blurb_input, genre_input, section_meanings], outputs=[messages, chatbot_history])
|
181 |
-
|
182 |
-
# def set_response_buttons(button_dict, button_name):
|
183 |
-
# print(button_name)
|
184 |
-
# return button_dict[button_name]
|
185 |
-
|
186 |
-
|
187 |
-
# with gr.Row(visible=True) as chat_row_0:
|
188 |
-
# textbox_0 = gr.Textbox(lines=1, label='Send a message', show_label=False, placeholder='Send a message', scale=4)
|
189 |
-
# submit_0 = gr.Button("Send", scale=2)
|
190 |
-
|
191 |
-
# for btn in typical_responses[2:]:
|
192 |
-
# btn.click(set_response_buttons, inputs=[button_dict, btn], outputs=[textbox]).then(model_chat,
|
193 |
-
# inputs=[genre_input, textbox, chatbot_history, messages, generated_audios],
|
194 |
-
# outputs=[textbox, chatbot_history, messages, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios, button_options]).then(reset_textbox, inputs=[textbox], outputs=[textbox]).then(
|
195 |
-
# update_response_options, [button_options, button_dict], typical_responses
|
196 |
-
# )
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
# with Modal(visible=False) as modal_0:
|
201 |
-
# gr.Markdown("Welcome to the AI songwriter! The AI songwriter will help you write a song. You can chat with the AI, generate lyrics, and listen to audio snippets. Let's start by chatting with the AI.")
|
202 |
-
# with Modal(visible=False) as modal:
|
203 |
-
# gr.Markdown("The chatbot is run by an AI songwriter. It can respond to your conversations, generate lyrics and audio, and edit prior generations.\n\nNow, continue and respond to this second question from the AI songwriter.")
|
204 |
-
# with Modal(visible=False) as modal_1:
|
205 |
-
# gr.Markdown("The AI songwriter has now proposed a first verse! You now have the option to hear an audio snippet, revise the lyrics, or continue to the next section. The latter two options continue the conversation, whereas the first starts audio generation models. Select the 'get audio snippet' button to continue to the next step.")
|
206 |
-
# with Modal(visible=False) as modal_2:
|
207 |
-
# gr.Markdown("Awesome! You generated your first audio snippet./n/n As you work thru each section, the generated snippets are populated on the right panel. You'll be able to listen thru snippets as you work thru the song. \n\n "
|
208 |
-
# "The current section is also displayed on the right panel. You'll be able to revise sections via the chat or directly via the right panel. \n\n "
|
209 |
-
# "You're ready to start your official song! Hit the 'Start' button to start.")
|
210 |
-
# start_button = gr.Button("Start")
|
211 |
-
|
212 |
-
# # start_button.click(change_tab, gr.Number(2, visible=False), tabs).then(update_generation_tab,
|
213 |
-
# # inputs=[],
|
214 |
-
# # outputs=[])
|
215 |
-
# continue_btn.click(lambda: Modal(visible=True), None, modal_0)
|
216 |
-
|
217 |
-
# def make_modal_visible(step_number):
|
218 |
-
# new_step_number = step_number + 1 if step_number in [0, 1, 2] else step_number
|
219 |
-
# modals = [Modal(visible=i == step_number) for i in range(3)]
|
220 |
-
# return new_step_number, *modals
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
# submit_0.click(update_textbox, [textbox_0, tutorial_step], [textbox_0]).then(model_chat,
|
226 |
-
# inputs=[genre_input, textbox_0, chatbot_history, messages, generated_audios],
|
227 |
-
# outputs=[textbox_0, chatbot_history, messages, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios, button_options]).then(reset_textbox, inputs=[textbox_0], outputs=[textbox_0]).then(
|
228 |
-
# update_response_options, [button_options, button_dict], typical_responses
|
229 |
-
# ).then(
|
230 |
-
# make_modal_visible, [tutorial_step], [tutorial_step, modal, modal_1, modal_2]
|
231 |
-
# )
|
232 |
-
# textbox_0.submit(update_textbox, [textbox_0, tutorial_step], [textbox_0]).then(model_chat,
|
233 |
-
# inputs=[genre_input, textbox_0, chatbot_history, messages, generated_audios],
|
234 |
-
# outputs=[textbox_0, chatbot_history, messages, current_section, current_lyrics, curr_tags, clip_to_continue, curr_audio, generated_audios, button_options]).then(reset_textbox, inputs=[textbox_0], outputs=[textbox_0]).then(
|
235 |
-
# update_response_options, [button_options, button_dict], typical_responses
|
236 |
-
# ).then(
|
237 |
-
# make_modal_visible, [tutorial_step], [tutorial_step, modal, modal_1, modal_2]
|
238 |
-
# )
|
239 |
-
|
240 |
|
241 |
|
242 |
with gr.TabItem("Generation", id=1): #index is 1
|
@@ -302,7 +145,7 @@ with gr.Blocks(css=css) as demo:
|
|
302 |
gr.TextArea(label="Lyrics", value=lyrics, interactive=False, show_label=False)
|
303 |
gr.TextArea(label="Instrumental", value=instrumental, interactive=False, show_label=False, max_lines=1)
|
304 |
|
305 |
-
gr.Markdown("""<center><font size=4>Current Generation</font></center>""")
|
306 |
current_section = gr.Textbox(label="Current section", value="Verse 1", interactive=False, show_label=True)
|
307 |
current_lyrics = gr.Textbox(label="Lyrics", value="", interactive=True, show_label=True)
|
308 |
with gr.Row():
|
@@ -312,11 +155,11 @@ with gr.Blocks(css=css) as demo:
|
|
312 |
audio_clips = [x[3] for x in generated_audios.value]
|
313 |
clip_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=audio_clips+[""], interactive=True)
|
314 |
#clip_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=audio_clips+[""], interactive=True)
|
315 |
-
songwriter_style = gr.Dropdown(label='Songwriter Style', value= "GPT 4o", choices=["GPT 4o", "d4vd"], interactive=True)
|
316 |
with gr.Row():
|
317 |
#curr_audio = gr.State("")
|
318 |
curr_audio = gr.HTML(label="Generated section")
|
319 |
-
regen = gr.Button("
|
320 |
|
321 |
|
322 |
section_meanings = gr.State(value="")
|
|
|
79 |
|
80 |
def change_tab(id):
|
81 |
return gr.Tabs(selected=id)
|
82 |
+
continue_btn.click(change_tab, gr.Number(1, visible=False), tabs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
|
85 |
with gr.TabItem("Generation", id=1): #index is 1
|
|
|
145 |
gr.TextArea(label="Lyrics", value=lyrics, interactive=False, show_label=False)
|
146 |
gr.TextArea(label="Instrumental", value=instrumental, interactive=False, show_label=False, max_lines=1)
|
147 |
|
148 |
+
gr.Markdown("""<center><font size=4>Edit Current Generation</font></center>""")
|
149 |
current_section = gr.Textbox(label="Current section", value="Verse 1", interactive=False, show_label=True)
|
150 |
current_lyrics = gr.Textbox(label="Lyrics", value="", interactive=True, show_label=True)
|
151 |
with gr.Row():
|
|
|
155 |
audio_clips = [x[3] for x in generated_audios.value]
|
156 |
clip_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=audio_clips+[""], interactive=True)
|
157 |
#clip_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=audio_clips+[""], interactive=True)
|
158 |
+
songwriter_style = gr.Dropdown(label='Songwriter Style', value= "GPT 4o", choices=["GPT 4o", "d4vd (Indie Rock Ballad - Male)", "Lizzy McAlpine (Indie Pop Folk - Female)", "Phoebe Bridgers (Pop Sad Rock - Female)", "Daniel Caesar (R&B/Soul - Male)"], interactive=True)
|
159 |
with gr.Row():
|
160 |
#curr_audio = gr.State("")
|
161 |
curr_audio = gr.HTML(label="Generated section")
|
162 |
+
regen = gr.Button("Submit edits")
|
163 |
|
164 |
|
165 |
section_meanings = gr.State(value="")
|
chat.py
CHANGED
@@ -355,7 +355,7 @@ def model_chat(genre_input, query: Optional[str], history: Optional[History], me
|
|
355 |
clips_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=[x[3] for x in generated_audios]+[""], interactive=True)
|
356 |
|
357 |
|
358 |
-
yield '', new_history, new_messages, "", "", "", clips_to_continue, None, generated_audios, [
|
359 |
|
360 |
else:
|
361 |
if "https://audiopipe.suno.ai/?item_id=" in updated_clip_url:
|
@@ -486,7 +486,7 @@ def model_chat(genre_input, query: Optional[str], history: Optional[History], me
|
|
486 |
|
487 |
generated_audios = update_song_links(generated_audios)
|
488 |
clips_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=[x[3] for x in generated_audios]+[""], interactive=True)
|
489 |
-
buttons = [
|
490 |
|
491 |
yield '', new_history, new_messages, snippet_lyrics.split("\n")[0], snippet_lyrics, snippet_instrumental_tags, clips_to_continue, None, generated_audios, buttons
|
492 |
|
|
|
355 |
clips_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=[x[3] for x in generated_audios]+[""], interactive=True)
|
356 |
|
357 |
|
358 |
+
yield '', new_history, new_messages, "", "", "", clips_to_continue, None, generated_audios, []
|
359 |
|
360 |
else:
|
361 |
if "https://audiopipe.suno.ai/?item_id=" in updated_clip_url:
|
|
|
486 |
|
487 |
generated_audios = update_song_links(generated_audios)
|
488 |
clips_to_continue = gr.Dropdown(label='Clip to continue', value = "", choices=[x[3] for x in generated_audios]+[""], interactive=True)
|
489 |
+
buttons = []
|
490 |
|
491 |
yield '', new_history, new_messages, snippet_lyrics.split("\n")[0], snippet_lyrics, snippet_instrumental_tags, clips_to_continue, None, generated_audios, buttons
|
492 |
|