moro23 commited on
Commit
e2bcf7c
1 Parent(s): d19b13c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -27,10 +27,18 @@ def loading_sound_file(sound_file, sr=22050, duration=10):
27
  # y = lib.util.fix_length(X, input_length)
28
  # extract normalized mfcc feature from data
29
 
30
- ## pad audio to same duration
 
 
 
 
31
  if round(dur) < duration:
32
- X = lib.util.fix_length(X, input_length)
33
-
 
 
 
 
34
  mfccs = np.mean(lib.feature.mfcc(y=X, sr=sr, n_mfcc=25).T,axis=0)
35
 
36
  ## Reshape to match the model's input shape
@@ -68,7 +76,7 @@ def heart_signal_classification(data):
68
  title = "Heart Signal Classification App"
69
  Input = gr.Audio(sources=["upload"], type="filepath")
70
  Output1 = gr.Textbox(label="Type Of Heart Signal")
71
- description = "Type Of Signal: Artifact, Murmur, Normal"
72
  iface = gr.Interface(fn=heart_signal_classification, inputs=Input, outputs=Output1, title=title, description=description)
73
 
74
  iface.launch(inline=False)
 
27
  # y = lib.util.fix_length(X, input_length)
28
  # extract normalized mfcc feature from data
29
 
30
+ # ## pad audio to same duration
31
+ # if round(dur) < duration:
32
+ # X = lib.util.fix_length(X, input_length)
33
+
34
+ # Pad or truncate audio file to the same duration
35
  if round(dur) < duration:
36
+ pad_amount = input_length - len(X)
37
+ X = np.pad(X, (0, pad_amount), mode='constant')
38
+ elif round(dur) > duration:
39
+ X = X[:input_length]
40
+
41
+
42
  mfccs = np.mean(lib.feature.mfcc(y=X, sr=sr, n_mfcc=25).T,axis=0)
43
 
44
  ## Reshape to match the model's input shape
 
76
  title = "Heart Signal Classification App"
77
  Input = gr.Audio(sources=["upload"], type="filepath")
78
  Output1 = gr.Textbox(label="Type Of Heart Signal")
79
+ description = "Type Of Signal: Artifact, Murmur, Normal, Extrastole, Extrahls"
80
  iface = gr.Interface(fn=heart_signal_classification, inputs=Input, outputs=Output1, title=title, description=description)
81
 
82
  iface.launch(inline=False)