├── .gitignore ├── Final_report.pdf ├── LICENSE ├── README.md ├── code ├── stft.py ├── wav_out │ ├── Rec01_out.wav │ ├── Rec02_out.wav │ ├── Rec03_out.wav │ ├── Rec04_out.wav │ ├── Rec05_out.wav │ ├── Rec06_out.wav │ ├── Rec07_out.wav │ ├── Rec08_out.wav │ ├── Rec09_out.wav │ ├── Rec10_out.wav │ ├── drv.wav │ ├── hello.wav │ ├── output │ │ ├── Rec01_out.wav │ │ ├── Rec02_out.wav │ │ ├── Rec03_out.wav │ │ ├── Rec04_out.wav │ │ ├── Rec05_rev.wav │ │ ├── Rec06_out.wav │ │ ├── Rec07_out.wav │ │ ├── Rec08_out.wav │ │ ├── Rec09_out.wav │ │ └── Rec10_out.wav │ └── sample_4ch_out.wav └── wpe.py ├── graphs ├── Rec01.png ├── Rec02.png ├── Rec03.png ├── Rec04.png ├── Rec05.png ├── Rec06.png ├── Rec07.png ├── Rec08.png ├── Rec09.png ├── Rec10.png ├── rec_values.odt └── sample_4ch.png ├── original_samples ├── Rec01_norev.mp3 ├── Rec02_norev.mp3 ├── Rec03_norev.mp3 ├── Rec04_norev.mp3 ├── Rec05_norev.mp3 ├── Rec06_norev.mp3 ├── Rec07_norev.mp3 ├── Rec08_norev.mp3 ├── Rec09_norev.mp3 ├── Rec10_norev.mp3 └── sample_4ch.wav ├── rev_added ├── Rec01_rev.wav ├── Rec02_rev.wav ├── Rec03_rev.wav ├── Rec04_rev.wav ├── Rec05_rev.wav ├── Rec06_rev.wav ├── Rec07_rev.wav ├── Rec08_rev.wav ├── Rec09_rev.wav ├── Rec10_rev.wav └── sample_4ch.wav ├── try ├── attachments.zip ├── sample1.wav ├── sample1_ch2.wav ├── sample1_ch3.wav ├── sample1_ch4.wav ├── sample2.wav ├── sample2_ch2.wav ├── sample2_ch3.wav ├── sample2_ch4.wav ├── sample3.wav ├── sample3_ch2.wav ├── sample3_ch3.wav └── sample3_ch4.wav ├── wav_sample ├── Deba1_rev_ch2.wav ├── Deba2_rev_ch2.wav ├── Deba3_rev_ch2.wav ├── Deba4_rev_ch2.wav ├── Deba5_rev_ch2.wav ├── Deep1_rev_ch2.wav ├── Deep2_rev_ch2.wav ├── Deep3_rev_ch2.wav ├── Deep4_rev_ch2.wav ├── Deep5_rev_ch2.wav ├── Me1.wav ├── Me1_2ch_rev.wav ├── Me1_4ch_rev.wav ├── drv_sample_4ch.wav ├── rec1_2ch_norev.wav ├── rec1_2ch_rev.wav ├── rec2_2ch_rev.wav ├── rec2_ch2_norev.wav ├── sample_4ch.wav └── svm.wav └── wav_sample_orig ├── S2_class_english.wav ├── drv_sample_4ch.wav ├── my_processed_audio_file.wav ├── mysamp.wav ├── new.py ├── new_drv.wav ├── octave-workspace └── sample_4ch.wav /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /Final_report.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/Final_report.pdf -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | MIT License 3 | 4 | Copyright (c) 2019 Teng Xiang 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Speech_Dereverberation 2 | Speech Dereverberation using weighted prediction error 3 | 4 | . 5 | ├── code 6 | │   ├── __pycache__ 7 | │   │   └── stft.cpython-36.pyc 8 | │   ├── stft.py 9 | │   └── wpe.py 10 | 11 | 12 | Run the wpe.py file using the command: 13 | cd Speech_Dereverberation/code/ ; python3 wpe.py ../rev_added/Rec01_rev.wav -o wav_out/Rec01_out.wav -p 200 14 | 15 | 16 | 17 | 18 | You can try this using your own samples. You can add reverb to your samples using a software known as "Audacity". 19 | -------------------------------------------------------------------------------- /code/stft.py: -------------------------------------------------------------------------------- 1 | 2 | import numpy as np 3 | from numpy.lib import stride_tricks 4 | 5 | def stft(data, frame_size=512, overlap=0.75, window=None): 6 | """ Multi-channel short time fourier transform 7 | 8 | Args: 9 | data: A 2-dimension numpy array with shape=(channels, samples) 10 | frame_size: An integer number of the length of the frame 11 | overlap: A float nonnegative number less than 1 indicating the overlap 12 | factor between adjacent frames 13 | 14 | Return: 15 | A 3-dimension numpy array with shape=(channels, frames, frequency_bins) 16 | """ 17 | 18 | assert(data.ndim == 2) 19 | 20 | if window == None: 21 | window = np.hanning(frame_size) 22 | frame_shift = int(frame_size - np.floor(overlap * frame_size)) 23 | cols = int(np.ceil((data.shape[1] - frame_size) / frame_shift)) + 1 24 | data = np.concatenate( 25 | (data, np.zeros((data.shape[0], frame_shift), dtype = np.float32)), 26 | axis = 1) 27 | 28 | samples = data.copy() 29 | frames = stride_tricks.as_strided( 30 | samples, 31 | shape=(samples.shape[0], cols, frame_size), 32 | strides=( 33 | samples.strides[-2], 34 | samples.strides[-1] * frame_shift, 35 | samples.strides[-1])).copy() 36 | frames *= window 37 | return np.fft.rfft(frames) 38 | 39 | def istft(data, frame_size=None, overlap=0.75, window=None): 40 | """ Multi-channel inverse short time fourier transform 41 | 42 | Args: 43 | data: A 3-dimension numpy array with shape=(channels, frames, frequency_bins) 44 | frame_size: An integer number of the length of the frame 45 | overlap: A float nonnegative number less than 1 indicating the overlap 46 | factor between adjacent frames 47 | 48 | Return: 49 | A 2-dimension numpy array with shape=(channels, samples) 50 | """ 51 | assert(data.ndim == 3) 52 | real_data = np.fft.irfft(data) 53 | #print("real data",real_data[0]) 54 | #print("real data",real_data[1]) 55 | # print("real data",real_data[2]) 56 | if frame_size == None: 57 | frame_size = real_data.shape[-1] 58 | 59 | #print(real_data.shape) 60 | frame_num = data.shape[-2] 61 | frame_shift = int(frame_size - np.floor(frame_size * overlap)) 62 | length = (frame_num - 1) * frame_shift + frame_size 63 | 64 | output = np.zeros((data.shape[0], length)) 65 | #print(data.shape[1]) 66 | for i in range(frame_num): 67 | index = i*frame_shift 68 | output[:, index : index + frame_size] += real_data[:,i] 69 | 70 | return output 71 | 72 | def log_spectrum(raw_data, frame_length=512): 73 | """Log magnitude spectrogram""" 74 | if raw_data.ndim == 1: 75 | raw_data = np.reshape(raw_data, (1, -1)) 76 | freq_data = stft(raw_data) 77 | phase = np.angle(freq_data) 78 | freq_data = np.abs(freq_data) 79 | freq_data = np.maximum(freq_data, 1e-8) 80 | log_data = np.log10(freq_data / freq_data.min()) 81 | return log_data, phase 82 | -------------------------------------------------------------------------------- /code/wav_out/Rec01_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec01_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec02_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec02_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec03_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec03_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec04_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec04_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec05_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec05_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec06_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec06_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec07_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec07_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec08_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec08_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec09_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec09_out.wav -------------------------------------------------------------------------------- /code/wav_out/Rec10_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/Rec10_out.wav -------------------------------------------------------------------------------- /code/wav_out/drv.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/drv.wav -------------------------------------------------------------------------------- /code/wav_out/hello.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/hello.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec01_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec01_out.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec02_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec02_out.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec03_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec03_out.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec04_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec04_out.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec05_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec05_rev.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec06_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec06_out.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec07_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec07_out.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec08_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec08_out.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec09_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec09_out.wav -------------------------------------------------------------------------------- /code/wav_out/output/Rec10_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/output/Rec10_out.wav -------------------------------------------------------------------------------- /code/wav_out/sample_4ch_out.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/code/wav_out/sample_4ch_out.wav -------------------------------------------------------------------------------- /code/wpe.py: -------------------------------------------------------------------------------- 1 | 2 | import stft 3 | import argparse 4 | import time 5 | import os 6 | import numpy as np 7 | import soundfile as sf 8 | from numpy.lib import stride_tricks 9 | import matplotlib.pyplot as plt 10 | import audioread 11 | 12 | class Configrations(): 13 | """Argument parser for WPE method configurations.""" 14 | def __init__(self): 15 | self.parser = argparse.ArgumentParser() 16 | 17 | def parse(self): 18 | self.parser.add_argument('filename') 19 | self.parser.add_argument( 20 | '-o', '--output', default='drv.wav', 21 | help='output filename') 22 | self.parser.add_argument( 23 | '-m', '--mic_num', type=int, default=3, 24 | help='number of input channels') 25 | self.parser.add_argument( 26 | '-n','--out_num', type=int, default=2, 27 | help='number of output channels') 28 | self.parser.add_argument( 29 | '-p', '--order', type=int, default=30, 30 | help='prediction order') 31 | self.cfgs = self.parser.parse_args() 32 | return self.cfgs 33 | 34 | 35 | class WpeMethod(object): 36 | """ 37 | Attributes: 38 | channels: Number of input channels. 39 | out_num: Number of output channels. 40 | p: An integer number of the prediction order. 41 | d: An integer number of the prediction delay. 42 | frame_size: An integer number of the length of the frame 43 | overlap: A float nonnegative number less than 1 indicating the overlap 44 | factor between adjacent frames 45 | """ 46 | def __init__(self, mic_num, out_num, order=30): 47 | self.channels = mic_num 48 | self.out_num = out_num 49 | self.p = order 50 | self.d = 2 51 | self.frame_size = 512 52 | self.overlap = 0.5 53 | self._iterations = 2 54 | 55 | @property 56 | def iterations(self): 57 | return self._iterations 58 | 59 | @iterations.setter 60 | def iterations(self, value): 61 | assert(int(value) > 0) 62 | self._iterations = int(value) 63 | 64 | def _display_cfgs(self): 65 | print('\nSettings:') 66 | print("Input channel: %d" % self.channels) 67 | print("Output channel: %d" % self.out_num) 68 | print("Prediction order: %d\n" % self.p) 69 | 70 | 71 | def run_offline(self, data): 72 | self._display_cfgs() 73 | time_start = time.time() 74 | print("Processing...") 75 | drv_data = self.__fdndlp(data) 76 | print("Done!\nTotal time: %f\n" % (time.time() - time_start)) 77 | return drv_data 78 | 79 | def __fdndlp(self, data): 80 | """Frequency-domain variance-normalized delayed linear prediction 81 | 82 | This is the core part of the WPE method. The variance-normalized 83 | linear prediciton algorithm is implemented in each frequency bin 84 | separately. Both the input and output signals are in time-domain. 85 | 86 | Args: 87 | data: A 2-dimension numpy array with shape=(channels, samples) 88 | 89 | Returns: 90 | A 2-dimension numpy array with shape=(output_channels, samples) 91 | """ 92 | 93 | freq_data = stft.stft( 94 | data / np.abs(data).max(), 95 | frame_size=self.frame_size, overlap=self.overlap) 96 | self.freq_num = freq_data.shape[-1] 97 | #print("Freq_data:",freq_data.shape[0]) 98 | #print("Freq_data:",freq_data.shape[1]) 99 | #print("Freq_data:",freq_data.shape[2]) 100 | 101 | #print("Freq_num",self.freq_num) 102 | 103 | drv_freq_data = freq_data[0:self.out_num].copy() 104 | for i in range(self.freq_num): 105 | xk = freq_data[:,:,i].T 106 | dk = self.__ndlp(xk) 107 | drv_freq_data[:,:,i] = dk.T 108 | 109 | #print("Shape of xk",xk.shape) 110 | drv_data = stft.istft( 111 | drv_freq_data, 112 | frame_size=self.frame_size, overlap=self.overlap) 113 | return drv_data / np.abs(drv_data).max() 114 | 115 | 116 | def __ndlp(self, xk): 117 | """Variance-normalized delayed liner prediction 118 | 119 | Here is the specific WPE algorithm implementation. The input should be 120 | the reverberant time-frequency signal in a single frequency bin and 121 | the output will be the dereverberated signal in the corresponding 122 | frequency bin. 123 | 124 | Args: 125 | xk: A 2-dimension numpy array with shape=(frames, input_chanels) 126 | 127 | Returns: 128 | A 2-dimension numpy array with shape=(frames, output_channels) 129 | """ 130 | cols = xk.shape[0] - self.d 131 | xk_buf = xk[:,0:self.out_num] 132 | xk = np.concatenate( 133 | (np.zeros((self.p - 1, self.channels)), xk), 134 | axis=0) 135 | #print("Xk",xk.shape) 136 | xk_tmp = xk[:,::-1].copy() 137 | #print("Xk_tmp",xk_tmp) 138 | frames = stride_tricks.as_strided( 139 | xk_tmp, 140 | shape=(self.channels * self.p, cols), 141 | strides=(xk_tmp.strides[-1], xk_tmp.strides[-1]*self.channels)) 142 | #print("PWE frame",frames.shape) 143 | frames = frames[::-1] 144 | #print("Frames",frames) 145 | sigma2 = np.mean(1 / (np.abs(xk_buf[self.d:]) ** 2), axis=1) 146 | for _ in range(self.iterations): 147 | x_cor_m = np.dot( 148 | np.dot(frames, np.diag(sigma2)), 149 | np.conj(frames.T)) 150 | x_cor_v = np.dot( 151 | frames, 152 | np.conj(xk_buf[self.d:] * sigma2.reshape(-1, 1))) 153 | coeffs = np.dot(np.linalg.inv(x_cor_m), x_cor_v) 154 | dk = xk_buf[self.d:] - np.dot(frames.T, np.conj(coeffs)) 155 | sigma2 = np.mean(1 / (np.abs(dk) ** 2), axis=1) 156 | return np.concatenate((xk_buf[0:self.d], dk)) 157 | 158 | def load_audio(self, filename): 159 | data, fs = sf.read(filename) 160 | data = data.T 161 | assert(data.shape[0] >= self.channels) 162 | if data.shape[0] > self.channels: 163 | print( 164 | "The number of the input channels is %d," % data.shape[0], 165 | "and only the first %d channels are loaded." % self.channels) 166 | data = data[0: self.channels] 167 | return data.copy(), fs 168 | 169 | def write_wav(self, data, fs, filename, path='wav_out'): 170 | if not os.path.exists(path): 171 | os.makedirs(path) 172 | filepath = os.path.join(path, filename) 173 | print('Write to file: %s.' % filepath) 174 | sf.write(filepath, data.T, fs, subtype='PCM_16') 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | if __name__ == '__main__': 183 | cfgs = Configrations().parse() 184 | # cfgs.filename = '../wav_sample/sample_4ch.wav' 185 | cfgs.mic_num = audioread.audio_open(cfgs.filename).channels 186 | cfgs.out_num = 2 187 | wpe = WpeMethod(cfgs.mic_num, cfgs.out_num, cfgs.order) 188 | data, fs = wpe.load_audio(cfgs.filename) 189 | drv_data = wpe.run_offline(data) 190 | #out_file = input() 191 | wpe.write_wav(drv_data, fs, cfgs.output) 192 | 193 | 194 | 195 | spec, _ = stft.log_spectrum(data[0]) 196 | original = spec[0].T 197 | 198 | 199 | spec, _ = stft.log_spectrum(drv_data[0]) 200 | reconstructed = spec[0].T 201 | 202 | original_use = np.hstack((np.ones((original.shape[0],1)),original)) 203 | #original_use = original 204 | 205 | 206 | error = np.mean(np.abs(original_use-reconstructed)) 207 | accuracy = 100 - error 208 | 209 | 210 | print("Percentage of accuracy(mean absolute error):",accuracy) 211 | 212 | 213 | plt.figure(figsize=(6.4, 9.6)) 214 | plt.subplot(2, 1, 1) 215 | plt.pcolor(original) 216 | 217 | 218 | 219 | plt.subplot(2 ,1, 2) 220 | plt.pcolor(reconstructed) 221 | plt.tight_layout() 222 | plt.show() 223 | 224 | 225 | 226 | -------------------------------------------------------------------------------- /graphs/Rec01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec01.png -------------------------------------------------------------------------------- /graphs/Rec02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec02.png -------------------------------------------------------------------------------- /graphs/Rec03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec03.png -------------------------------------------------------------------------------- /graphs/Rec04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec04.png -------------------------------------------------------------------------------- /graphs/Rec05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec05.png -------------------------------------------------------------------------------- /graphs/Rec06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec06.png -------------------------------------------------------------------------------- /graphs/Rec07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec07.png -------------------------------------------------------------------------------- /graphs/Rec08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec08.png -------------------------------------------------------------------------------- /graphs/Rec09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec09.png -------------------------------------------------------------------------------- /graphs/Rec10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/Rec10.png -------------------------------------------------------------------------------- /graphs/rec_values.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/rec_values.odt -------------------------------------------------------------------------------- /graphs/sample_4ch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/graphs/sample_4ch.png -------------------------------------------------------------------------------- /original_samples/Rec01_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec01_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec02_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec02_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec03_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec03_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec04_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec04_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec05_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec05_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec06_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec06_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec07_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec07_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec08_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec08_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec09_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec09_norev.mp3 -------------------------------------------------------------------------------- /original_samples/Rec10_norev.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/Rec10_norev.mp3 -------------------------------------------------------------------------------- /original_samples/sample_4ch.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/original_samples/sample_4ch.wav -------------------------------------------------------------------------------- /rev_added/Rec01_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec01_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec02_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec02_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec03_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec03_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec04_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec04_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec05_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec05_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec06_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec06_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec07_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec07_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec08_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec08_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec09_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec09_rev.wav -------------------------------------------------------------------------------- /rev_added/Rec10_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/Rec10_rev.wav -------------------------------------------------------------------------------- /rev_added/sample_4ch.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/rev_added/sample_4ch.wav -------------------------------------------------------------------------------- /try/attachments.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/attachments.zip -------------------------------------------------------------------------------- /try/sample1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample1.wav -------------------------------------------------------------------------------- /try/sample1_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample1_ch2.wav -------------------------------------------------------------------------------- /try/sample1_ch3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample1_ch3.wav -------------------------------------------------------------------------------- /try/sample1_ch4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample1_ch4.wav -------------------------------------------------------------------------------- /try/sample2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample2.wav -------------------------------------------------------------------------------- /try/sample2_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample2_ch2.wav -------------------------------------------------------------------------------- /try/sample2_ch3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample2_ch3.wav -------------------------------------------------------------------------------- /try/sample2_ch4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample2_ch4.wav -------------------------------------------------------------------------------- /try/sample3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample3.wav -------------------------------------------------------------------------------- /try/sample3_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample3_ch2.wav -------------------------------------------------------------------------------- /try/sample3_ch3.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample3_ch3.wav -------------------------------------------------------------------------------- /try/sample3_ch4.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/try/sample3_ch4.wav -------------------------------------------------------------------------------- /wav_sample/Deba1_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deba1_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deba2_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deba2_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deba3_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deba3_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deba4_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deba4_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deba5_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deba5_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deep1_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deep1_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deep2_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deep2_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deep3_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deep3_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deep4_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deep4_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Deep5_rev_ch2.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Deep5_rev_ch2.wav -------------------------------------------------------------------------------- /wav_sample/Me1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Me1.wav -------------------------------------------------------------------------------- /wav_sample/Me1_2ch_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Me1_2ch_rev.wav -------------------------------------------------------------------------------- /wav_sample/Me1_4ch_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/Me1_4ch_rev.wav -------------------------------------------------------------------------------- /wav_sample/drv_sample_4ch.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/drv_sample_4ch.wav -------------------------------------------------------------------------------- /wav_sample/rec1_2ch_norev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/rec1_2ch_norev.wav -------------------------------------------------------------------------------- /wav_sample/rec1_2ch_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/rec1_2ch_rev.wav -------------------------------------------------------------------------------- /wav_sample/rec2_2ch_rev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/rec2_2ch_rev.wav -------------------------------------------------------------------------------- /wav_sample/rec2_ch2_norev.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/rec2_ch2_norev.wav -------------------------------------------------------------------------------- /wav_sample/sample_4ch.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/sample_4ch.wav -------------------------------------------------------------------------------- /wav_sample/svm.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample/svm.wav -------------------------------------------------------------------------------- /wav_sample_orig/S2_class_english.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample_orig/S2_class_english.wav -------------------------------------------------------------------------------- /wav_sample_orig/drv_sample_4ch.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample_orig/drv_sample_4ch.wav -------------------------------------------------------------------------------- /wav_sample_orig/my_processed_audio_file.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample_orig/my_processed_audio_file.wav -------------------------------------------------------------------------------- /wav_sample_orig/mysamp.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample_orig/mysamp.wav -------------------------------------------------------------------------------- /wav_sample_orig/new.py: -------------------------------------------------------------------------------- 1 | # Import the package and create an audio effects chain function. 2 | from pysndfx import AudioEffectsChain 3 | 4 | fx = ( 5 | AudioEffectsChain() 6 | .highshelf() 7 | .reverb() 8 | .phaser() 9 | .delay() 10 | .lowshelf() 11 | ) 12 | 13 | infile = 'S2_class_english.wav' 14 | outfile = 'my_processed_audio_file.wav' 15 | 16 | # Apply phaser and reverb directly to an audio file. 17 | fx(infile, outfile) 18 | -------------------------------------------------------------------------------- /wav_sample_orig/new_drv.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample_orig/new_drv.wav -------------------------------------------------------------------------------- /wav_sample_orig/octave-workspace: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample_orig/octave-workspace -------------------------------------------------------------------------------- /wav_sample_orig/sample_4ch.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Debapriya-Tula/Speech_Dereverberation/fa439d121156b0074bee4003c87c0824517abbb0/wav_sample_orig/sample_4ch.wav --------------------------------------------------------------------------------