From c4d773b9f73c81c6d484c639adff4feaeffe04d1 Mon Sep 17 00:00:00 2001 From: drumpt Date: Sun, 10 Oct 2021 13:42:41 +0000 Subject: [PATCH] Fix SNR calculate error, total_snrlevels, requirements.txt --- audiolib.py | 2 +- noisyspeech_synthesizer.cfg | 4 ++-- noisyspeech_synthesizer.py | 2 +- requirements.txt | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/audiolib.py b/audiolib.py index cd999efe..ad0ec248 100644 --- a/audiolib.py +++ b/audiolib.py @@ -65,7 +65,7 @@ def snr_mixer(clean, noise, snr): rmsnoise = (noise**2).mean()**0.5 # Set the noise level for a given SNR - noisescalar = np.sqrt(rmsclean / (10**(snr/20)) / rmsnoise) + noisescalar = rmsclean / (10**(snr/20)) / rmsnoise noisenewlevel = noise * noisescalar noisyspeech = clean + noisenewlevel return clean, noisenewlevel, noisyspeech diff --git a/noisyspeech_synthesizer.cfg b/noisyspeech_synthesizer.cfg index 71992c01..5ea8c513 100644 --- a/noisyspeech_synthesizer.cfg +++ b/noisyspeech_synthesizer.cfg @@ -21,8 +21,8 @@ audio_length: 10 silence_length: 0.2 total_hours: 1 snr_lower: 0 -snr_upper: 40 -total_snrlevels: 5 +snr_upper: 20 +total_snrlevels: 5 noise_dir: None speech_dir: None diff --git a/noisyspeech_synthesizer.py b/noisyspeech_synthesizer.py index 86c136e1..6874a9ca 100644 --- a/noisyspeech_synthesizer.py +++ b/noisyspeech_synthesizer.py @@ -12,7 +12,7 @@ def main(cfg): snr_lower = float(cfg["snr_lower"]) snr_upper = float(cfg["snr_upper"]) - total_snrlevels = float(cfg["total_snrlevels"]) + total_snrlevels = int(cfg["total_snrlevels"]) clean_dir = os.path.join(os.path.dirname(__file__), 'clean_train') if cfg["speech_dir"]!='None': diff --git a/requirements.txt b/requirements.txt index 462407cc..b74458bb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ numpy -glob +glob2 soundfile scipy -os configparser \ No newline at end of file