-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwave_align.py
22 lines (20 loc) · 874 Bytes
/
wave_align.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import numpy as np
import soundfile as sf
from scipy import fftpack, signal
from channeldelay import wavedelay
os.chdir('/home/simon/Music/rec_jan25/')
pdata = []
count = 1
filenames = [f for f in os.listdir('.') if os.path.isfile(f)]
for filename in [f for f in filenames if f.endswith(".wav")]:
oriWave, oriSampleRate = sf.read(os.path.join('.', filename))
print('fileopened:', os.path.join('.',filename))
recWave, recSampleRate = sf.read(os.path.join('.', 'rec_file/rec_'+filename))
print('fileopened:', os.path.join('.', 'rec_file/rec_'+filename))
delay = wavedelay(oriWave, recWave, oriSampleRate, 60)
recWave = recWave[delay:]
oriWave = oriWave[:len(recWave)]
sf.write('aligned_'+filename, oriWave, oriSampleRate)
sf.write('aligned_rec_'+filename, recWave, recSampleRate)
print('aligning complete! file:', filename)