bandhav commited on
Commit
932f9eb
1 Parent(s): de110b1

Updated error message

Browse files
Files changed (1) hide show
  1. app.py +2 -4
app.py CHANGED
@@ -43,13 +43,11 @@ def waveformer(audio, label_choices):
43
  # Read input audio
44
  fs, mixture = audio
45
  if fs != 44100:
46
- raise ValueError(fs)
47
  mixture = torch.from_numpy(
48
  mixture).unsqueeze(0).unsqueeze(0).to(torch.float) / (2.0 ** 15)
49
 
50
  # Construct the query vector
51
- if len(label_choices) == 0:
52
- raise ValueError(label_choices)
53
  query = torch.zeros(1, len(TARGETS))
54
  for t in label_choices:
55
  query[0, TARGETS.index(t)] = 1.
@@ -62,4 +60,4 @@ def waveformer(audio, label_choices):
62
 
63
  label_checkbox = gr.CheckboxGroup(choices=TARGETS)
64
  demo = gr.Interface(fn=waveformer, inputs=['audio', label_checkbox], outputs="audio")
65
- demo.launch()
 
43
  # Read input audio
44
  fs, mixture = audio
45
  if fs != 44100:
46
+ raise ValueError("Sampling rate must be 44100, but got %d" % fs)
47
  mixture = torch.from_numpy(
48
  mixture).unsqueeze(0).unsqueeze(0).to(torch.float) / (2.0 ** 15)
49
 
50
  # Construct the query vector
 
 
51
  query = torch.zeros(1, len(TARGETS))
52
  for t in label_choices:
53
  query[0, TARGETS.index(t)] = 1.
 
60
 
61
  label_checkbox = gr.CheckboxGroup(choices=TARGETS)
62
  demo = gr.Interface(fn=waveformer, inputs=['audio', label_checkbox], outputs="audio")
63
+ demo.launch(show_error=True)