.wav文件到numpay数组

时间:2018-08-25 10:26:32

标签: python numpy wav numpy-ndarray

我是python语言的新手,我有大约100个 .wav文件示例,我想从我的电脑中读取并将其转换为 numpy-array 并给出我文件的输出。但直到现在我都无法实现。所以我需要帮助

我正在关注此操作,但是我知道我只是给出了不相关的输出,因为它不是我的wav文件

import numpy as np
from scipy.io.wavfile import write

# Samples per second
sps = 44100

# Frequency / pitch of the sine wave
freq_hz = 440.0

# Duration
duration_s = 5.0

# NumpPy magic
each_sample_number = np.arange(duration_s * sps)
waveform = np.sin(2 * np.pi * each_sample_number * freq_hz / sps)
waveform_quiet = waveform * 0.3
waveform_integers = np.int16(waveform_quiet * 32767)

# Write the .wav file
write('first_sine_wave.wav', sps, waveform_integers)

0 个答案:

没有答案