Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding effects to make voice sound like it’s over a telephone

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?

like image 858
hrs Avatar asked Feb 19 '14 05:02

hrs


People also ask

How do you sound like a phone?

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.


1 Answers

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))
like image 162
hrs Avatar answered Nov 09 '22 18:11

hrs