2cylu2 commited on
Commit
d852991
·
verified ·
1 Parent(s): 5a73a18

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
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
- detected_key = detect_key(
23
- audio_dir=input_audio_path,
24
  extension=ext,
25
- device=DEVICE
 
26
  )
27
 
28
- print("Detected key raw output:", detected_key)
29
 
30
- if isinstance(detected_key, list):
31
- detected_key = detected_key[0]
 
 
32
 
33
  labels = LabelList()
34
  labels.labels.append(
35
  AudioLabel(
36
  t=0.0,
37
  duration=5.0,
38
- label=str(detected_key),
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)