Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Add noise_root to allow relative paths for noise files
Browse files Browse the repository at this point in the history
  • Loading branch information
apark263 committed Oct 19, 2016
1 parent 8681215 commit 468ee21
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# ChangeLog

## v0.2.3 (2016-10-18)
* Add noise_root path option for relative noise index files
* Bug fix for filterbank shaping
* Bug fix for stereo image provider creation

Expand Down
2 changes: 1 addition & 1 deletion loader/src/etl_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ audio::transformer::transformer(const audio::config& config) :
specgram::create_filterbanks(_cfg.num_filters, _cfg.frame_length_tn, _cfg.sample_freq_hz,
_filterbank);
}
_noisemaker = make_shared<noise_clips>(_cfg.noise_index_file);
_noisemaker = make_shared<noise_clips>(_cfg.noise_index_file, _cfg.noise_root);

}

Expand Down
2 changes: 2 additions & 0 deletions loader/src/etl_audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ namespace nervana {
std::string window_type {"hann"};

std::string noise_index_file {};
std::string noise_root {};

/** Sample rate of input audio in hertz */
uint32_t sample_freq_hz {16000};
Expand Down Expand Up @@ -203,6 +204,7 @@ namespace nervana {
ADD_SCALAR(feature_type, mode::OPTIONAL),
ADD_SCALAR(window_type, mode::OPTIONAL),
ADD_SCALAR(noise_index_file, mode::OPTIONAL),
ADD_SCALAR(noise_root, mode::OPTIONAL),
ADD_SCALAR(add_noise_probability, mode::OPTIONAL),
ADD_SCALAR(sample_freq_hz, mode::OPTIONAL),
ADD_DISTRIBUTION(time_scale_fraction, mode::OPTIONAL, [](decltype(time_scale_fraction) v){ return v.a() <= v.b(); }),
Expand Down
8 changes: 5 additions & 3 deletions loader/src/noise_clips.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
using namespace std;
using namespace nervana;

noise_clips::noise_clips(const std::string noiseIndexFile)
noise_clips::noise_clips(const std::string noiseIndexFile, const std::string noiseRoot)
{
if (!noiseIndexFile.empty()) {
load_index(noiseIndexFile);
load_index(noiseIndexFile, noiseRoot);
load_data();
}
}
Expand All @@ -38,7 +38,7 @@ noise_clips::~noise_clips()
}
}

void noise_clips::load_index(const std::string& index_file)
void noise_clips::load_index(const std::string& index_file, const std::string& root_dir)
{
ifstream ifs(index_file);

Expand All @@ -48,6 +48,8 @@ void noise_clips::load_index(const std::string& index_file)

string line;
while(getline(ifs, line)) {
if(!root_dir.empty())
line = path_join(root_dir, line);
_noise_files.push_back(line);
}

Expand Down
4 changes: 2 additions & 2 deletions loader/src/noise_clips.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace nervana {

class nervana::noise_clips {
public:
noise_clips(const std::string noiseIndexFile);
noise_clips(const std::string noiseIndexFile, const std::string noiseRoot);
virtual ~noise_clips();
void addNoise(cv::Mat& wav_mat,
bool add_noise,
Expand All @@ -34,7 +34,7 @@ class nervana::noise_clips {


private:
void load_index(const std::string& index_file);
void load_index(const std::string& index_file, const std::string& root_dir);
void load_data();
void read_noise(std::string& noise_file, int* dataLen);

Expand Down

0 comments on commit 468ee21

Please sign in to comment.