Spaces:
Running
Running
Luis
commited on
Commit
·
ce2098c
1
Parent(s):
0bce4f4
add SNORING_INDEX
Browse files- python/util/plt_util.py +2 -1
- test.py +4 -2
python/util/plt_util.py
CHANGED
@@ -28,6 +28,7 @@ def plt_line(y_points, sample_rate=16000):
|
|
28 |
fig, ax = plt.subplots()
|
29 |
ax.xaxis.set_major_formatter(ticker.FuncFormatter(update_ticks))
|
30 |
plt.plot(y_points)
|
|
|
31 |
|
32 |
# plot to image
|
33 |
buffer = BytesIO()
|
@@ -44,7 +45,7 @@ def plt_mfcc(single_channel, sample_rate):
|
|
44 |
plt.figure()
|
45 |
librosa.display.specshow(log_mel_spec, sr=sample_rate, x_axis='time', y_axis='mel')
|
46 |
plt.colorbar(format='%+2.0f dB') # 右边的色度条
|
47 |
-
plt.title('
|
48 |
|
49 |
# plot to image
|
50 |
buffer = BytesIO()
|
|
|
28 |
fig, ax = plt.subplots()
|
29 |
ax.xaxis.set_major_formatter(ticker.FuncFormatter(update_ticks))
|
30 |
plt.plot(y_points)
|
31 |
+
plt.title('Waveform')
|
32 |
|
33 |
# plot to image
|
34 |
buffer = BytesIO()
|
|
|
45 |
plt.figure()
|
46 |
librosa.display.specshow(log_mel_spec, sr=sample_rate, x_axis='time', y_axis='mel')
|
47 |
plt.colorbar(format='%+2.0f dB') # 右边的色度条
|
48 |
+
plt.title('MFCC')
|
49 |
|
50 |
# plot to image
|
51 |
buffer = BytesIO()
|
test.py
CHANGED
@@ -20,6 +20,8 @@ OUT_PCM = 'PCM_16'
|
|
20 |
CLASS_MAP_FILE = 'res/yamnet_class_map.csv'
|
21 |
DEBUG = True
|
22 |
SNORING_TOP_N = 7
|
|
|
|
|
23 |
|
24 |
|
25 |
# Methods
|
@@ -81,7 +83,7 @@ def predict_waveform(idx, waveform):
|
|
81 |
score = means[index]
|
82 |
name = class_names[index]
|
83 |
|
84 |
-
if
|
85 |
snoring_score = score
|
86 |
top_n_res += ' ' + format_float(score) + ' [' + truncate_str(name, 4) + '], '
|
87 |
|
@@ -112,7 +114,7 @@ def predict_uri(audio_uri1, audio_uri2):
|
|
112 |
wav_input = audio_to_wav(mp3_input) if not mp3_input.endswith('.mp3') == True else mp3_input
|
113 |
predict_seconds = int(str(sys.argv[2])) if len(sys.argv) > 2 else 1
|
114 |
|
115 |
-
predict_samples =
|
116 |
single_channel, sc_sample_rate = read_single_channel(wav_input)
|
117 |
splits = split_given_size(single_channel, predict_samples)
|
118 |
result += ' sc_sample_rate: ' + str(sc_sample_rate) + '\n'
|
|
|
20 |
CLASS_MAP_FILE = 'res/yamnet_class_map.csv'
|
21 |
DEBUG = True
|
22 |
SNORING_TOP_N = 7
|
23 |
+
SNORING_INDEX = 38
|
24 |
+
IN_MODEL_SAMPLES = 15600
|
25 |
|
26 |
|
27 |
# Methods
|
|
|
83 |
score = means[index]
|
84 |
name = class_names[index]
|
85 |
|
86 |
+
if index == SNORING_INDEX:
|
87 |
snoring_score = score
|
88 |
top_n_res += ' ' + format_float(score) + ' [' + truncate_str(name, 4) + '], '
|
89 |
|
|
|
114 |
wav_input = audio_to_wav(mp3_input) if not mp3_input.endswith('.mp3') == True else mp3_input
|
115 |
predict_seconds = int(str(sys.argv[2])) if len(sys.argv) > 2 else 1
|
116 |
|
117 |
+
predict_samples = IN_MODEL_SAMPLES # OUT_SAMPLE_RATE * predict_seconds
|
118 |
single_channel, sc_sample_rate = read_single_channel(wav_input)
|
119 |
splits = split_given_size(single_channel, predict_samples)
|
120 |
result += ' sc_sample_rate: ' + str(sc_sample_rate) + '\n'
|