天天看点

Python 立体声音频生成

  1. pip安装依赖
    pip install wave
    pip install numpy
    pip install soundfile
               
  2. 立体声音频生成示例代码
    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)
               

继续阅读