Spaces:
Running
Running
added: exception handling
Browse files
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title: ChatGPT
|
3 |
-
emoji:
|
4 |
colorFrom: green
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
|
|
1 |
---
|
2 |
+
title: TR-ChatGPT
|
3 |
+
emoji: 🥁
|
4 |
colorFrom: green
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
app.py
CHANGED
@@ -121,11 +121,15 @@ def generate_rhythm(query, state):
|
|
121 |
resolution = 8 # default
|
122 |
|
123 |
# Extract rhythm table
|
124 |
-
|
125 |
-
|
|
|
|
|
126 |
|
127 |
-
|
128 |
-
|
|
|
|
|
129 |
|
130 |
return [(SR, audio_data), text_output]
|
131 |
# %%
|
@@ -142,7 +146,7 @@ with gr.Blocks() as demo:
|
|
142 |
with gr.Column():
|
143 |
# gr.Markdown("Ask ChatGPT to generate rhythm patterns")
|
144 |
gr.Markdown("***Hey TR-ChatGPT, give me a drum pattern!***")
|
145 |
-
gr.Markdown("
|
146 |
with gr.Row():
|
147 |
with gr.Column():
|
148 |
inp = gr.Textbox(placeholder="Give me a Hiphop rhythm pattern with some reggae twist!")
|
|
|
121 |
resolution = 8 # default
|
122 |
|
123 |
# Extract rhythm table
|
124 |
+
try:
|
125 |
+
assert 1 == 0
|
126 |
+
table = "|" + "|".join(text_output.split('|')[1:-1]) + "|"
|
127 |
+
audio_data = convert_table_to_audio(table, resolution)
|
128 |
|
129 |
+
# loop x4
|
130 |
+
audio_data = np.tile(audio_data, 4)
|
131 |
+
except:
|
132 |
+
audio_data = np.zeros(1)
|
133 |
|
134 |
return [(SR, audio_data), text_output]
|
135 |
# %%
|
|
|
146 |
with gr.Column():
|
147 |
# gr.Markdown("Ask ChatGPT to generate rhythm patterns")
|
148 |
gr.Markdown("***Hey TR-ChatGPT, give me a drum pattern!***")
|
149 |
+
gr.Markdown("Use the following drums. Kick drum:BD, Snare drum:SD, Closed-hihat:CH, Open-hihat:OH, Low-tom:LT, Mid-tom:MT, High-tom:HT and 'x' for an accented beat, 'o' for a weak beat!")
|
150 |
with gr.Row():
|
151 |
with gr.Column():
|
152 |
inp = gr.Textbox(placeholder="Give me a Hiphop rhythm pattern with some reggae twist!")
|