Python 立體聲音訊生成
阿新 • • 發佈:2021-01-10
-
pip安裝依賴
pip install wave pip install numpy pip install soundfile
-
立體聲音訊生成示例程式碼
import wave import numpy as np import soundfile as sf # read wave files left_data, _ = sf.read("test_1.wav") right_data, _ = sf.read("test_2.wav") # A 2D array where the left and right tones are contained in their respective rows stereo = np.vstack((left_data, right_data)) # Reshape 2D array so that the left and right tones are contained in their respective columns stereo = stereo.transpose() sf.write('stereoAudio.wav', stereo, samplerate=44100)