利用scipy实现声音处理

from scipy.io import wavfile
import numpy as np
import matplotlib.pyplot as plt
sample_rate, data = wavfile.read("Alarm01.wav") # 加载声音,返回采样频率,声音数据
print("Data type", data.dtype, "Shape", data.shape)

Data type int16 Shape (122868, 2)

repeated = np.array(list(data)*2) # 重复音频片段
wavfile.write("a.wav", sample_rate, repeated) # 绘制声音
plt.figure(figsize=(10,5))

plt.subplot(1,2,1)
plt.title("Original")
plt.plot(data)

plt.subplot(1,2,2)
plt.title("Repeated")
plt.plot(repeated)

plt.show()

利用scipy实现声音处理
声音数据下载:https://files.cnblogs.com/files/LiJinrun/Alarm01.zip

上一篇:Leetcode 718.最长重复子数组(Maximum Length of Repeated Subarray)


下一篇:961. N-Repeated Element in Size 2N Array