forked from jtkim-kaist/VAD
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1783e2
commit feec9c1
Showing
65 changed files
with
458 additions
and
27 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
18014,1,float32 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
function acoustic_feat_ex( data_dir, save_dir ) | ||
|
||
rng(0); | ||
%% Directory setting | ||
|
||
% system(['rm -rf ', save_dir]); | ||
% | ||
% system(['mkdir ', save_dir]); | ||
system(['mkdir ', save_dir, '/Normalize_Factor']); | ||
system(['mkdir ', save_dir, '/Labels']); | ||
|
||
%% Parameter setting | ||
|
||
audio_sr = 16000; | ||
split_num = 1; | ||
name_mrcg = [save_dir, '/se_mrcg']; | ||
name_label = [save_dir, '/se_label']; | ||
|
||
audio_list = getAllFiles(data_dir, 'FileFilter', '\.wav$'); | ||
label_list = getAllFiles(data_dir, 'FileFilter', '\.mat$'); | ||
|
||
winlen = ceil(audio_sr*25*0.001); %window length (default : 25 ms) | ||
winstep = ceil(audio_sr*10*0.001); %window step (default : 10 ms) | ||
|
||
train_mean = 0; | ||
train_std = 0; | ||
|
||
for i = 1:1:length(audio_list) | ||
clc | ||
fprintf("MRCG extraction %d/%d ...\n", i, length(audio_list)); | ||
%% Read audio | ||
|
||
noisy_speech = audioread(audio_list{i}); % noisy_speech load | ||
noisy_speech = noisy_speech(1:(length(noisy_speech)-mod(length(noisy_speech), split_num))); | ||
noisy_speech = reshape(noisy_speech, [], split_num); | ||
|
||
%% Caliculate MRCG | ||
mrcg = cell(split_num, 1); | ||
|
||
for j = 1:1:split_num | ||
mrcg{j, 1} = MRCG_features(noisy_speech(:, j), audio_sr)'; | ||
% imagesc(s(20000:20500,:)*1000) | ||
end | ||
|
||
mrcg_mat = cell2mat(mrcg); | ||
|
||
size(mrcg_mat) | ||
%% Save normalization factor | ||
|
||
temp_mean = mean(mrcg_mat,1); | ||
temp_std = std(mrcg_mat,1,1); | ||
save([save_dir, '/Normalize_Factor/normalize_factor_', sprintf('%3.3d', i)],'temp_mean', 'temp_std'); | ||
train_mean = temp_mean + train_mean; | ||
train_std = temp_std + train_std; | ||
|
||
%% Read label | ||
label = cell2mat(struct2cell(load(label_list{i}))); % label load | ||
|
||
%% Save framed label & MRCG | ||
framed_label = Truelabel2Trueframe( label, winlen, winstep ); | ||
length(framed_label) | ||
if (length(mrcg_mat) > length(framed_label)) | ||
binary_saver( name_mrcg, mrcg_mat(1:length(framed_label), :), i ); | ||
binary_saver( name_label, framed_label, i ); | ||
else | ||
binary_saver( name_mrcg, mrcg_mat, i ); | ||
binary_saver( name_label, framed_label(1:length(mrcg_mat), 1), i ); | ||
end | ||
end | ||
|
||
disp('MRCG extraction done.') | ||
%% Save global normalization factor | ||
|
||
global_mean = train_mean / length(audio_list); | ||
global_std = train_std / length(audio_list); | ||
save([save_dir, '/global_normalize_factor'], 'global_mean', 'global_std'); | ||
|
||
%% Move label data | ||
|
||
feat_list = getAllFiles(save_dir); | ||
|
||
for i=1:1:length(feat_list) | ||
if ~isempty(strfind(feat_list{i}, 'label')) | ||
[pathstr, name, ext] = fileparts(feat_list{i}); | ||
new_path = [pathstr, '/Labels/', name, ext]; | ||
movefile(feat_list{i}, new_path); | ||
end | ||
end | ||
|
||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
clc | ||
clear | ||
data_dir = '/home/sbie/github_2/VAD_Toolkit/VAD/data/raw'; | ||
save_dir = '/home/sbie/github_2/VAD_Toolkit/VAD/data/feat'; | ||
acoustic_feat_ex( 0.3, data_dir, save_dir ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import sys | ||
|
||
sys.path.insert(0, './lib/python') | ||
import VAD_Proposed as Vp | ||
import VAD_DNN as Vd | ||
import VAD_bDNN as Vb | ||
import VAD_LSTM_2 as Vl | ||
import scipy.io as sio | ||
import os, getopt | ||
# norm_dir = "./norm_data" | ||
# data_dir = "./sample_data" | ||
# ckpt_name = '/model9918and41.ckpt-2' | ||
# model_dir = "./saved_model" | ||
# valid_batch_size = 4134 | ||
|
||
if __name__ == '__main__': | ||
|
||
try: | ||
opts, args = getopt.getopt(sys.argv[1:], 'h', ["data_dir=", "save_dir="]) | ||
except getopt.GetoptError as err: | ||
print(str(err)) | ||
sys.exit(1) | ||
|
||
if len(opts) != 2: | ||
print("arguments are not enough.") | ||
sys.exit(1) | ||
|
||
for opt, arg in opts: | ||
if opt == '-h': | ||
sys.exit(0) | ||
elif opt == '--data_dir': | ||
data_dir = str(arg) | ||
elif opt == '--save_dir': | ||
save_dir = str(arg) | ||
|
||
data_dir = os.path.abspath('../..') + '/data' + data_dir | ||
train_data_dir = data_dir + '/train' | ||
valid_data_dir = data_dir + '/valid' | ||
|
||
save_dir = os.path.abspath('../..') + '/data' + save_dir | ||
train_save_dir = save_dir + '/train' | ||
valid_save_dir = save_dir + '/valid' | ||
|
||
os.system("rm -rf " + save_dir) | ||
os.system("mkdir " + save_dir) | ||
os.system("mkdir " + save_dir + '/train') | ||
os.system("mkdir " + save_dir + '/valid') | ||
|
||
os.system("matlab -r \"try acoustic_feat_ex(\'%s\',\'%s\'); catch; end; quit\"" % (train_data_dir, train_save_dir)) | ||
os.system("matlab -r \"try acoustic_feat_ex(\'%s\',\'%s\'); catch; end; quit\"" % (valid_data_dir, valid_save_dir)) | ||
|
||
# os.system("rm -rf") | ||
print("done") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import sys | ||
|
||
sys.path.insert(0, './lib/python') | ||
import VAD_Proposed as Vp | ||
import VAD_DNN as Vd | ||
import VAD_bDNN as Vb | ||
import VAD_LSTM_2 as Vl | ||
import scipy.io as sio | ||
import os, getopt | ||
# norm_dir = "./norm_data" | ||
# data_dir = "./sample_data" | ||
# ckpt_name = '/model9918and41.ckpt-2' | ||
# model_dir = "./saved_model" | ||
# valid_batch_size = 4134 | ||
|
||
if __name__ == '__main__': | ||
|
||
try: | ||
opts, args = getopt.getopt(sys.argv[1:], 'hm:e:', ["train_step=", "prj_dir="]) | ||
except getopt.GetoptError as err: | ||
print(str(err)) | ||
sys.exit(1) | ||
|
||
if len(opts) != 4: | ||
print("arguments are not enough.") | ||
sys.exit(1) | ||
|
||
for opt, arg in opts: | ||
if opt == '-h': | ||
sys.exit(0) | ||
elif opt == '-m': | ||
mode = int(arg) | ||
elif opt == '-e': | ||
extract_feat = int(arg) | ||
elif opt == '--train_step': | ||
train_step = int(arg) | ||
elif opt == '--prj_dir': | ||
prj_dir = str(arg) | ||
|
||
data_dir = prj_dir + '/data/raw' | ||
print(data_dir) | ||
train_data_dir = data_dir + '/train' | ||
valid_data_dir = data_dir + '/valid' | ||
|
||
save_dir = prj_dir + '/data/feat' | ||
train_save_dir = save_dir + '/train' | ||
valid_save_dir = save_dir + '/valid' | ||
|
||
if extract_feat: | ||
|
||
os.system("rm -rf " + save_dir) | ||
os.system("mkdir " + save_dir) | ||
os.system("mkdir " + save_dir + '/train') | ||
os.system("mkdir " + save_dir + '/valid') | ||
os.system( | ||
"matlab -r \"try acoustic_feat_ex(\'%s\',\'%s\'); catch; end; quit\"" % (train_data_dir, train_save_dir)) | ||
os.system( | ||
"matlab -r \"try acoustic_feat_ex(\'%s\',\'%s\'); catch; end; quit\"" % (valid_data_dir, valid_save_dir)) | ||
|
||
train_norm_dir = save_dir + '/train/global_normalize_factor.mat' | ||
test_norm_dir = prj_dir + '/norm_data/global_normalize_factor.mat' | ||
|
||
os.system("cp %s %s" % (train_norm_dir, test_norm_dir)) | ||
|
||
if mode == 0: | ||
|
||
logs_dir = prj_dir + '/logs' | ||
os.system("rm -rf " + logs_dir + '/train') | ||
os.system("rm -rf " + logs_dir + '/valid') | ||
os.system("mkdir " + logs_dir + '/train') | ||
os.system("mkdir " + logs_dir + '/valid') | ||
|
||
Vd.train_config(save_dir+'/train', save_dir+'/valid', prj_dir+'/logs', 256, | ||
train_step, 'train') | ||
|
||
Vd.main() | ||
# os.system("rm -rf") | ||
print("done") |
Oops, something went wrong.