Spaces:
Running
Running
working: interface
Browse files
app.py
CHANGED
@@ -60,7 +60,7 @@ def convert_table_to_audio(markdown_table, resolution=8, bpm = 120.0):
|
|
60 |
pm_inst = pretty_midi.Instrument(0, is_drum=True) # midi instrument
|
61 |
pm.instruments.append(pm_inst)
|
62 |
|
63 |
-
note_length = (60. / bpm) * (4.0 / resolution) #
|
64 |
|
65 |
for i in range(len(rhythm_pattern)):
|
66 |
for j in range(1, len(rhythm_pattern[i])):
|
@@ -75,7 +75,7 @@ def convert_table_to_audio(markdown_table, resolution=8, bpm = 120.0):
|
|
75 |
audio_data = pm.fluidsynth()
|
76 |
|
77 |
# cut off the reverb section
|
78 |
-
audio_data = audio_data[:int(SR*note_length*resolution)]
|
79 |
return audio_data
|
80 |
|
81 |
def get_answer(question):
|
@@ -121,12 +121,22 @@ def generate_rhythm(query):
|
|
121 |
|
122 |
import gradio as gr
|
123 |
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
)
|
|
|
|
|
|
|
|
|
129 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
# %%
|
131 |
|
132 |
# %%
|
|
|
60 |
pm_inst = pretty_midi.Instrument(0, is_drum=True) # midi instrument
|
61 |
pm.instruments.append(pm_inst)
|
62 |
|
63 |
+
note_length = (60. / bpm) * (4.0 / resolution) # note duration
|
64 |
|
65 |
for i in range(len(rhythm_pattern)):
|
66 |
for j in range(1, len(rhythm_pattern[i])):
|
|
|
75 |
audio_data = pm.fluidsynth()
|
76 |
|
77 |
# cut off the reverb section
|
78 |
+
audio_data = audio_data[:int(SR*note_length*resolution)] # for looping, cut the tail
|
79 |
return audio_data
|
80 |
|
81 |
def get_answer(question):
|
|
|
121 |
|
122 |
import gradio as gr
|
123 |
|
124 |
+
with gr.Blocks() as demo:
|
125 |
+
gr.Markdown("Ask ChatGPT to generate rhythm patterns")
|
126 |
+
with gr.Row():
|
127 |
+
inp = gr.Textbox(placeholder="Give me a Hiphop rhythm pattern with some reggae twist!")
|
128 |
+
with gr.Column():
|
129 |
+
out_audio = gr.Audio()
|
130 |
+
out_text = gr.Textbox(placeholder="ChatGPT output")
|
131 |
+
btn = gr.Button("Generate")
|
132 |
+
btn.click(fn=generate_rhythm, inputs=inp, outputs=[out_audio, out_text])
|
133 |
demo.launch()
|
134 |
+
# demo = gr.Interface(
|
135 |
+
# fn=generate_rhythm,
|
136 |
+
# inputs=gr.Textbox(label="command",show_label=True, placeholder="Give me a dope beat!", visible=True).style(container=False),
|
137 |
+
# outputs=["audio", "text"]
|
138 |
+
# )
|
139 |
+
# demo.launch()
|
140 |
# %%
|
141 |
|
142 |
# %%
|