spycoder commited on
Commit
ab2603c
·
1 Parent(s): 7df6f30

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -2
app.py CHANGED
@@ -43,8 +43,19 @@ The model was trained on Thai audio recordings with the following sentences:
43
 
44
 
45
 
46
- def predict(file_path):
 
47
  max_length = 100000
 
 
 
 
 
 
 
 
 
 
48
 
49
  model.eval()
50
  with torch.no_grad():
@@ -66,7 +77,7 @@ def predict(file_path):
66
  ans = "no_parkinson"
67
  else:
68
  ans = "parkinson"
69
- return ans
70
  gr.Interface(
71
  fn=predict,
72
  inputs=[
 
43
 
44
 
45
 
46
+ def predict(microphone,file_upload):
47
+
48
  max_length = 100000
49
+ warn_output = " "
50
+ if (microphone is not None) and (file_upload is not None):
51
+ warn_output = (
52
+ "WARNING: You've uploaded an audio file and used the microphone. "
53
+ "The recorded file from the microphone will be used and the uploaded audio will be discarded.\n"
54
+ )
55
+
56
+ elif (microphone is None) and (file_upload is None):
57
+ return "ERROR: You have to either use the microphone or upload an audio file"
58
+ file_path = microphone if microphone is not None else file_upload
59
 
60
  model.eval()
61
  with torch.no_grad():
 
77
  ans = "no_parkinson"
78
  else:
79
  ans = "parkinson"
80
+ return warn_output + ans
81
  gr.Interface(
82
  fn=predict,
83
  inputs=[