naotokui commited on
Commit
58a268c
1 Parent(s): 257684d

added: exception handling

Browse files
Files changed (2) hide show
  1. README.md +2 -2
  2. app.py +9 -5
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
- title: ChatGPT 707
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
- table = "|" + "|".join(text_output.split('|')[1:-1]) + "|"
125
- audio_data = convert_table_to_audio(table, resolution)
 
 
126
 
127
- # loop x2
128
- audio_data = np.tile(audio_data, 4)
 
 
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("You 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. Use 'x' for an accented beat, 'o' for a weak beat. ", elem_id="label")
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!")