def write_wave ( path , audio , sample_rate ) : with contextlib . closing ( wave . open ( path , 'wb' ) ) as wf : wf . setnchannels ( 1 ) wf . setsampwidth ( 2 ) wf . setframerate ( sample_rate ) wf . writeframes ( audio )
how to save audio as wave file python
Writes a . wav file .
def write_wave(path, audio, sample_rate):
    """Writes a .wav file.

    Takes path, PCM audio data, and sample rate.
    """
    with contextlib.closing(wave.open(path, 'wb')) as wf:
        wf.setnchannels(1)
        wf.setsampwidth(2)
        wf.setframerate(sample_rate)
        wf.writeframes(audio)