Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -23,7 +23,7 @@ pipe = transformers.pipeline(
|
|
| 23 |
)
|
| 24 |
print('Done')
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
71 1310 0 20 0
|
| 29 |
48 330 350 20 0
|
|
@@ -44,7 +44,6 @@ default_prefix = '''pitch duration wait velocity instrument
|
|
| 44 |
69 1970 0 20 0
|
| 45 |
48 330 350 20 0
|
| 46 |
'''
|
| 47 |
-
default_prefix_len = default_prefix.count('\n') - 2
|
| 48 |
|
| 49 |
|
| 50 |
|
|
@@ -94,7 +93,7 @@ def postprocess(txt, path):
|
|
| 94 |
|
| 95 |
with gr.Blocks() as demo:
|
| 96 |
chatbot_box = gr.Chatbot(type="messages", render_markdown=False, sanitize_html=False)
|
| 97 |
-
prefix_box = gr.TextArea(value=
|
| 98 |
with gr.Row():
|
| 99 |
submit_btn = gr.Button("Submit")
|
| 100 |
clear_btn = gr.Button("Clear")
|
|
@@ -104,6 +103,10 @@ with gr.Blocks() as demo:
|
|
| 104 |
audio_box = gr.Audio()
|
| 105 |
midi_box = gr.File()
|
| 106 |
piano_roll_box = gr.Image()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
def user_fn(user_message, history: list):
|
| 109 |
return "", history + [{"role": "user", "content": user_message}]
|
|
@@ -112,11 +115,7 @@ with gr.Blocks() as demo:
|
|
| 112 |
def bot_fn(history: list):
|
| 113 |
prefix = history[-1]["content"]
|
| 114 |
history.append({"role": "assistant", "content": ""})
|
| 115 |
-
# if prefix.startswith("pitch duration wait\n\n"):
|
| 116 |
history[-1]["content"] += "Generating with the given prefix...\n"
|
| 117 |
-
# else:
|
| 118 |
-
# history[-1]["content"] += f"Generating from scratch with a default prefix of {default_prefix_len} notes...\n"
|
| 119 |
-
# prefix = default_prefix
|
| 120 |
queue = Queue()
|
| 121 |
class MyStreamer:
|
| 122 |
def put(self, tokens):
|
|
|
|
| 23 |
)
|
| 24 |
print('Done')
|
| 25 |
|
| 26 |
+
example_prefix = '''pitch duration wait velocity instrument
|
| 27 |
|
| 28 |
71 1310 0 20 0
|
| 29 |
48 330 350 20 0
|
|
|
|
| 44 |
69 1970 0 20 0
|
| 45 |
48 330 350 20 0
|
| 46 |
'''
|
|
|
|
| 47 |
|
| 48 |
|
| 49 |
|
|
|
|
| 93 |
|
| 94 |
with gr.Blocks() as demo:
|
| 95 |
chatbot_box = gr.Chatbot(type="messages", render_markdown=False, sanitize_html=False)
|
| 96 |
+
prefix_box = gr.TextArea(value="", label="prefix")
|
| 97 |
with gr.Row():
|
| 98 |
submit_btn = gr.Button("Submit")
|
| 99 |
clear_btn = gr.Button("Clear")
|
|
|
|
| 103 |
audio_box = gr.Audio()
|
| 104 |
midi_box = gr.File()
|
| 105 |
piano_roll_box = gr.Image()
|
| 106 |
+
example_box = gr.Examples(
|
| 107 |
+
[["Chopin"], ["Bach"], ["Beethoven"], ["Debussy"], ["Boogie Woogie"], [example_prefix]],
|
| 108 |
+
inputs=prefix_box,
|
| 109 |
+
)
|
| 110 |
|
| 111 |
def user_fn(user_message, history: list):
|
| 112 |
return "", history + [{"role": "user", "content": user_message}]
|
|
|
|
| 115 |
def bot_fn(history: list):
|
| 116 |
prefix = history[-1]["content"]
|
| 117 |
history.append({"role": "assistant", "content": ""})
|
|
|
|
| 118 |
history[-1]["content"] += "Generating with the given prefix...\n"
|
|
|
|
|
|
|
|
|
|
| 119 |
queue = Queue()
|
| 120 |
class MyStreamer:
|
| 121 |
def put(self, tokens):
|