AbdullaShafeeg commited on
Commit
1b639b7
·
1 Parent(s): cf4974d
Files changed (1) hide show
  1. app.py +38 -38
app.py CHANGED
@@ -63,44 +63,44 @@ if upload_file is not None:
63
  # with open("output.wav", 'wb') as wav_file:
64
  # wav_file.write(wav_make)
65
 
66
- sr, waveform = wavfile.read('saved_file.wav')
67
- snore = 0
68
- other = 0
69
- s=0
70
- n=16000
71
- endReached = False
72
-
73
- while(endReached==False):
74
- input_tensor = torch.tensor(waveform[s:n]).unsqueeze(0).to(torch.float32)
75
- result = model(input_tensor)
76
- if np.abs(result[0][0]) > np.abs(result[0][1]):
77
- other += 1
78
- else:
79
- snore += 1
80
- s += 16000
81
- n += 16000
82
- if(n >= len(waveform)):
83
- endReached = True
84
-
85
- # PERCENTAGE OF SNORING PLOT
86
-
87
- total = snore + other
88
- snore_percentage = (snore / total) * 100
89
- other_percentage = (other / total) * 100
90
-
91
- categories = ["Snore", "Other"]
92
- percentages = [snore_percentage, other_percentage]
93
-
94
- plt.figure(figsize=(8, 4))
95
- plt.barh(categories, percentages, color=['#ff0033', '#00ffee'])
96
- plt.xlabel('Percentage')
97
- plt.title('Percentage of Snoring')
98
- plt.xlim(0, 100)
99
-
100
- for i, percentage in enumerate(percentages):
101
- plt.text(percentage, i, f' {percentage:.2f}%', va='center')
102
-
103
- st.pyplot(plt)
104
 
105
 
106
 
 
63
  # with open("output.wav", 'wb') as wav_file:
64
  # wav_file.write(wav_make)
65
 
66
+ sr, waveform = wavfile.read('saved_file.wav')
67
+ snore = 0
68
+ other = 0
69
+ s=0
70
+ n=16000
71
+ endReached = False
72
+
73
+ while(endReached==False):
74
+ input_tensor = torch.tensor(waveform[s:n]).unsqueeze(0).to(torch.float32)
75
+ result = model(input_tensor)
76
+ if np.abs(result[0][0]) > np.abs(result[0][1]):
77
+ other += 1
78
+ else:
79
+ snore += 1
80
+ s += 16000
81
+ n += 16000
82
+ if(n >= len(waveform)):
83
+ endReached = True
84
+
85
+ # PERCENTAGE OF SNORING PLOT
86
+
87
+ total = snore + other
88
+ snore_percentage = (snore / total) * 100
89
+ other_percentage = (other / total) * 100
90
+
91
+ categories = ["Snore", "Other"]
92
+ percentages = [snore_percentage, other_percentage]
93
+
94
+ plt.figure(figsize=(8, 4))
95
+ plt.barh(categories, percentages, color=['#ff0033', '#00ffee'])
96
+ plt.xlabel('Percentage')
97
+ plt.title('Percentage of Snoring')
98
+ plt.xlim(0, 100)
99
+
100
+ for i, percentage in enumerate(percentages):
101
+ plt.text(percentage, i, f' {percentage:.2f}%', va='center')
102
+
103
+ st.pyplot(plt)
104
 
105
 
106