How to use the audiofile.AudioFile.gen_default_wav function in audiofile

To help you get started, we’ve selected a few audiofile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pezz89 / PySoundConcat / src / sppysound / pitch_shift.py View on Github external
def shift(sigin, pitch):
    if np.isnan(pitch):
        return sigin
    input_filepath = "./.shift_input.wav"
    output_filepath = "./.shift_output.wav"

    shift_input = AudioFile.gen_default_wav(
        input_filepath,
        overwrite_existing=True,
        mode='w',
        channels=1,
    )
    # Write grain to be shifted to file
    shift_input.write_frames(sigin)
    # Close file
    del shift_input

    cents = 1200. * np.log2(pitch)
    p_shift_args = ["sox", input_filepath, output_filepath, "pitch", str(cents)]

    p = subprocess.Popen(p_shift_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    (output, err) = p.communicate()

audiofile

Fast reading of all kind of audio files

MIT
Latest version published 3 months ago

Package Health Score

62 / 100
Full package analysis

Similar packages