I understand that when a person speaks over a telephone, he sounds a bit different because of the frequency response of the microphone/channel/speaker being used.
I have been playing with speech signal processing in Python. I was wondering how simulate this effect. Do I need to design a filter?
Flexible digital eq would work best for this technique. Next, high pass the low frequencies to around 300-600Hz and Low pass the high frequencies above 4-7kHz. This will now limit the frequency response, making the vocal thinner, more lo-fi, replicating how it would sound playing through a small telephone speaker.
Here is the code. Works fine for me:
from scipy.signal import lfilter, butter
from scipy.io.wavfile import read,write
from numpy import array, int16
import sys
def butter_params(low_freq, high_freq, fs, order=5):
nyq = 0.5 * fs
low = low_freq / nyq
high = high_freq / nyq
b, a = butter(order, [low, high], btype='band')
return b, a
def butter_bandpass_filter(data, low_freq, high_freq, fs, order=5):
b, a = butter_params(low_freq, high_freq, fs, order=order)
y = lfilter(b, a, data)
return y
if __name__ == '__main__':
fs,audio = read(sys.argv[1])
low_freq = 300.0
high_freq = 3000.0
filtered_signal = butter_bandpass_filter(audio, low_freq, high_freq, fs, order=6)
fname = sys.argv[1].split('.wav')[0] + '_moded.wav'
write(fname,fs,array(filtered_signal,dtype=int16))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With