gpt4 book ai didi

python - 添加效果使语音听起来像通过电话

转载 作者:太空狗 更新时间:2023-10-29 20:30:40 26 4
gpt4 key购买 nike

我知道当一个人通过电话讲话时,由于所使用的麦克风/ channel /扬声器的频率响应不同,他的声音听起来会有些不同。

我一直在研究 Python 中的语音信号处理。我想知道如何模拟这种效果。我需要设计过滤器吗?

最佳答案

这是代码。适合我:

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))

关于python - 添加效果使语音听起来像通过电话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21871834/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com