Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,23 +19,26 @@ def process_fn(input_audio_path):
|
|
| 19 |
try:
|
| 20 |
ext = input_audio_path.split(".")[-1].lower()
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
extension=ext,
|
| 25 |
-
device=DEVICE
|
|
|
|
| 26 |
)
|
| 27 |
|
| 28 |
-
print("
|
| 29 |
|
| 30 |
-
if
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
labels = LabelList()
|
| 34 |
labels.labels.append(
|
| 35 |
AudioLabel(
|
| 36 |
t=0.0,
|
| 37 |
duration=5.0,
|
| 38 |
-
label=
|
| 39 |
amplitude=0.8,
|
| 40 |
description="Detected by S-KEY",
|
| 41 |
color=OutputLabel.rgb_color_to_int(255, 100, 100, 0.8),
|
|
@@ -48,6 +51,7 @@ def process_fn(input_audio_path):
|
|
| 48 |
print("Error:", e)
|
| 49 |
raise e
|
| 50 |
|
|
|
|
| 51 |
# Build Gradio Endpoint
|
| 52 |
with gr.Blocks() as demo:
|
| 53 |
input_audio = gr.Audio(label="Input Audio", type="filepath").harp_required(True)
|
|
|
|
| 19 |
try:
|
| 20 |
ext = input_audio_path.split(".")[-1].lower()
|
| 21 |
|
| 22 |
+
detected_keys = detect_key(
|
| 23 |
+
input_audio_path,
|
| 24 |
extension=ext,
|
| 25 |
+
device=DEVICE,
|
| 26 |
+
cli=False
|
| 27 |
)
|
| 28 |
|
| 29 |
+
print("Raw output:", detected_keys)
|
| 30 |
|
| 31 |
+
if not detected_keys:
|
| 32 |
+
raise ValueError("No key detected")
|
| 33 |
+
|
| 34 |
+
detected_key = detected_keys[0] # because function returns list[str]
|
| 35 |
|
| 36 |
labels = LabelList()
|
| 37 |
labels.labels.append(
|
| 38 |
AudioLabel(
|
| 39 |
t=0.0,
|
| 40 |
duration=5.0,
|
| 41 |
+
label=detected_key,
|
| 42 |
amplitude=0.8,
|
| 43 |
description="Detected by S-KEY",
|
| 44 |
color=OutputLabel.rgb_color_to_int(255, 100, 100, 0.8),
|
|
|
|
| 51 |
print("Error:", e)
|
| 52 |
raise e
|
| 53 |
|
| 54 |
+
|
| 55 |
# Build Gradio Endpoint
|
| 56 |
with gr.Blocks() as demo:
|
| 57 |
input_audio = gr.Audio(label="Input Audio", type="filepath").harp_required(True)
|