Spaces:
Running
Running
Bring the Space up to the pyharp example standard (taxonomy tags, __main__ guard, show_error, v0.4.0)
Browse files- app.py +109 -108
- requirements.txt +1 -0
app.py
CHANGED
|
@@ -42,7 +42,7 @@ model_card = ModelCard(
|
|
| 42 |
"The control values are echoed into the output label descriptions."
|
| 43 |
),
|
| 44 |
author="TEAMuP",
|
| 45 |
-
tags=[
|
| 46 |
)
|
| 47 |
|
| 48 |
|
|
@@ -231,112 +231,113 @@ def process_fn(
|
|
| 231 |
|
| 232 |
|
| 233 |
# Build the Gradio endpoint
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
|
| 242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
)
|
| 244 |
-
.harp_required(False)
|
| 245 |
-
.set_info("Passed through unchanged. Bundled reference audio is used if empty."),
|
| 246 |
-
gr.File(
|
| 247 |
-
type="filepath",
|
| 248 |
-
label="Input MIDI",
|
| 249 |
-
file_types=[".mid", ".midi"]
|
| 250 |
-
)
|
| 251 |
-
.harp_required(False)
|
| 252 |
-
.set_info("Passed through unchanged. Bundled reference MIDI is used if empty."),
|
| 253 |
-
gr.File(
|
| 254 |
-
type="filepath",
|
| 255 |
-
label="Input File",
|
| 256 |
-
file_types=[".txt", ".csv", ".json", ".nam"]
|
| 257 |
-
)
|
| 258 |
-
.harp_required(False)
|
| 259 |
-
.set_info("A generic file. HARP shows this as a file picker, not a track."),
|
| 260 |
-
gr.Slider(
|
| 261 |
-
minimum=0,
|
| 262 |
-
maximum=60,
|
| 263 |
-
step=1,
|
| 264 |
-
value=0,
|
| 265 |
-
label="Processing Delay (s)",
|
| 266 |
-
info="Stalls processing, so the cancel button can be tested."
|
| 267 |
-
),
|
| 268 |
-
gr.Slider(
|
| 269 |
-
minimum=0.0,
|
| 270 |
-
maximum=1.0,
|
| 271 |
-
step=0.01,
|
| 272 |
-
value=0.5,
|
| 273 |
-
label="Gain",
|
| 274 |
-
info="A fractional slider (unused)."
|
| 275 |
-
),
|
| 276 |
-
gr.Number(
|
| 277 |
-
minimum=1,
|
| 278 |
-
maximum=16,
|
| 279 |
-
step=1,
|
| 280 |
-
value=4,
|
| 281 |
-
label="Repetitions",
|
| 282 |
-
info="A number box (unused)."
|
| 283 |
-
),
|
| 284 |
-
gr.Dropdown(
|
| 285 |
-
choices=["first", "second", "third"],
|
| 286 |
-
value="second",
|
| 287 |
-
label="Mode",
|
| 288 |
-
info="A dropdown (unused)."
|
| 289 |
-
),
|
| 290 |
-
gr.Dropdown(
|
| 291 |
-
choices=["reverb", "delay", "chorus"],
|
| 292 |
-
value=["reverb", "chorus"],
|
| 293 |
-
multiselect=True,
|
| 294 |
-
label="Effects",
|
| 295 |
-
info="A dropdown allowing more than one selection (unused)."
|
| 296 |
-
),
|
| 297 |
-
gr.Checkbox(
|
| 298 |
-
value=True,
|
| 299 |
-
label="Audio Labels",
|
| 300 |
-
info="Emit output labels over the audio track."
|
| 301 |
-
),
|
| 302 |
-
gr.Checkbox(
|
| 303 |
-
value=True,
|
| 304 |
-
label="MIDI Labels",
|
| 305 |
-
info="Emit output labels over the MIDI track."
|
| 306 |
-
),
|
| 307 |
-
gr.Textbox(
|
| 308 |
-
value="Hello World",
|
| 309 |
-
label="Text Prompt",
|
| 310 |
-
info="A text box. Written to the output file when no input file is given."
|
| 311 |
-
),
|
| 312 |
-
]
|
| 313 |
-
|
| 314 |
-
# A gr.JSON output receives the LabelList and is drawn over the tracks.
|
| 315 |
-
# Order must match the values returned by process_fn.
|
| 316 |
-
output_components = [
|
| 317 |
-
gr.Audio(
|
| 318 |
-
type="filepath",
|
| 319 |
-
label="Output Audio"
|
| 320 |
-
).set_info("The input audio, unchanged."),
|
| 321 |
-
gr.File(
|
| 322 |
-
type="filepath",
|
| 323 |
-
label="Output MIDI",
|
| 324 |
-
file_types=[".mid", ".midi"]
|
| 325 |
-
).set_info("The input MIDI, unchanged."),
|
| 326 |
-
gr.JSON(
|
| 327 |
-
label="Output Labels"
|
| 328 |
-
).set_info("Labels drawn over the output tracks."),
|
| 329 |
-
gr.File(
|
| 330 |
-
type="filepath",
|
| 331 |
-
label="Output File"
|
| 332 |
-
).set_info("A generic file output."),
|
| 333 |
-
]
|
| 334 |
-
|
| 335 |
-
app = build_endpoint(
|
| 336 |
-
model_card=model_card,
|
| 337 |
-
input_components=input_components,
|
| 338 |
-
output_components=output_components,
|
| 339 |
-
process_fn=process_fn,
|
| 340 |
-
)
|
| 341 |
|
| 342 |
-
demo.queue().launch(share=True, show_error=True, pwa=True)
|
|
|
|
| 42 |
"The control values are echoed into the output label descriptions."
|
| 43 |
),
|
| 44 |
author="TEAMuP",
|
| 45 |
+
tags=[Category.UTILITY, 'example', 'ui', 'test', 'v3'],
|
| 46 |
)
|
| 47 |
|
| 48 |
|
|
|
|
| 231 |
|
| 232 |
|
| 233 |
# Build the Gradio endpoint
|
| 234 |
+
if __name__ == "__main__":
|
| 235 |
+
with gr.Blocks() as demo:
|
| 236 |
+
# Audio and MIDI components become tracks in HARP. A gr.File with any
|
| 237 |
+
# other extension becomes a GUI file picker instead. Every input here is
|
| 238 |
+
# optional, so the app can be run without loading anything.
|
| 239 |
+
# Order must match the process_fn signature.
|
| 240 |
+
input_components = [
|
| 241 |
+
gr.Audio(
|
| 242 |
+
type="filepath",
|
| 243 |
+
label="Input Audio"
|
| 244 |
+
)
|
| 245 |
+
.harp_required(False)
|
| 246 |
+
.set_info("Passed through unchanged. Bundled reference audio is used if empty."),
|
| 247 |
+
gr.File(
|
| 248 |
+
type="filepath",
|
| 249 |
+
label="Input MIDI",
|
| 250 |
+
file_types=[".mid", ".midi"]
|
| 251 |
+
)
|
| 252 |
+
.harp_required(False)
|
| 253 |
+
.set_info("Passed through unchanged. Bundled reference MIDI is used if empty."),
|
| 254 |
+
gr.File(
|
| 255 |
+
type="filepath",
|
| 256 |
+
label="Input File",
|
| 257 |
+
file_types=[".txt", ".csv", ".json", ".nam"]
|
| 258 |
+
)
|
| 259 |
+
.harp_required(False)
|
| 260 |
+
.set_info("A generic file. HARP shows this as a file picker, not a track."),
|
| 261 |
+
gr.Slider(
|
| 262 |
+
minimum=0,
|
| 263 |
+
maximum=60,
|
| 264 |
+
step=1,
|
| 265 |
+
value=0,
|
| 266 |
+
label="Processing Delay (s)",
|
| 267 |
+
info="Stalls processing, so the cancel button can be tested."
|
| 268 |
+
),
|
| 269 |
+
gr.Slider(
|
| 270 |
+
minimum=0.0,
|
| 271 |
+
maximum=1.0,
|
| 272 |
+
step=0.01,
|
| 273 |
+
value=0.5,
|
| 274 |
+
label="Gain",
|
| 275 |
+
info="A fractional slider (unused)."
|
| 276 |
+
),
|
| 277 |
+
gr.Number(
|
| 278 |
+
minimum=1,
|
| 279 |
+
maximum=16,
|
| 280 |
+
step=1,
|
| 281 |
+
value=4,
|
| 282 |
+
label="Repetitions",
|
| 283 |
+
info="A number box (unused)."
|
| 284 |
+
),
|
| 285 |
+
gr.Dropdown(
|
| 286 |
+
choices=["first", "second", "third"],
|
| 287 |
+
value="second",
|
| 288 |
+
label="Mode",
|
| 289 |
+
info="A dropdown (unused)."
|
| 290 |
+
),
|
| 291 |
+
gr.Dropdown(
|
| 292 |
+
choices=["reverb", "delay", "chorus"],
|
| 293 |
+
value=["reverb", "chorus"],
|
| 294 |
+
multiselect=True,
|
| 295 |
+
label="Effects",
|
| 296 |
+
info="A dropdown allowing more than one selection (unused)."
|
| 297 |
+
),
|
| 298 |
+
gr.Checkbox(
|
| 299 |
+
value=True,
|
| 300 |
+
label="Audio Labels",
|
| 301 |
+
info="Emit output labels over the audio track."
|
| 302 |
+
),
|
| 303 |
+
gr.Checkbox(
|
| 304 |
+
value=True,
|
| 305 |
+
label="MIDI Labels",
|
| 306 |
+
info="Emit output labels over the MIDI track."
|
| 307 |
+
),
|
| 308 |
+
gr.Textbox(
|
| 309 |
+
value="Hello World",
|
| 310 |
+
label="Text Prompt",
|
| 311 |
+
info="A text box. Written to the output file when no input file is given."
|
| 312 |
+
),
|
| 313 |
+
]
|
| 314 |
+
|
| 315 |
+
# A gr.JSON output receives the LabelList and is drawn over the tracks.
|
| 316 |
+
# Order must match the values returned by process_fn.
|
| 317 |
+
output_components = [
|
| 318 |
+
gr.Audio(
|
| 319 |
+
type="filepath",
|
| 320 |
+
label="Output Audio"
|
| 321 |
+
).set_info("The input audio, unchanged."),
|
| 322 |
+
gr.File(
|
| 323 |
+
type="filepath",
|
| 324 |
+
label="Output MIDI",
|
| 325 |
+
file_types=[".mid", ".midi"]
|
| 326 |
+
).set_info("The input MIDI, unchanged."),
|
| 327 |
+
gr.JSON(
|
| 328 |
+
label="Output Labels"
|
| 329 |
+
).set_info("Labels drawn over the output tracks."),
|
| 330 |
+
gr.File(
|
| 331 |
+
type="filepath",
|
| 332 |
+
label="Output File"
|
| 333 |
+
).set_info("A generic file output."),
|
| 334 |
+
]
|
| 335 |
+
|
| 336 |
+
app = build_endpoint(
|
| 337 |
+
model_card=model_card,
|
| 338 |
+
input_components=input_components,
|
| 339 |
+
output_components=output_components,
|
| 340 |
+
process_fn=process_fn,
|
| 341 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
|
| 343 |
+
demo.queue().launch(share=True, show_error=True, pwa=True)
|
requirements.txt
CHANGED
|
@@ -1 +1,2 @@
|
|
| 1 |
git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.0
|
|
|
|
|
|
| 1 |
git+https://github.com/TEAMuP-dev/pyharp.git@v0.4.0
|
| 2 |
+
spaces>=0.51.1
|