Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace resampy with pysox for audio resampling #49

Open
justinsalamon opened this issue Jun 25, 2020 · 0 comments
Open

Replace resampy with pysox for audio resampling #49

justinsalamon opened this issue Jun 25, 2020 · 0 comments
Labels
enhancement New feature or request

Comments

@justinsalamon
Copy link
Collaborator

Turns out resampy is SLOW. We could speed openl3 quite a bit by swapping it out with pysox, resample the audio into a tempfile and load the templfile for further processing.

with tempfile.TemporaryDirectory() as tempdir:
    filename48 = os.path.join(tempdir, os.path.basename(os.path.splitext(file_path)[0]) + "_48.wav"# resample to 48000 Hz
    tfm = sox.Transformer()
    tfm.convert(samplerate= 48000, n_channels=1)
    tfm.build(file_path, filename48)

    # load the audio file
    sr = 48000
    audio, srload = librosa.load(filename48, sr=None)
    assert srload == sr

NOTE: this example assumes wav input, and would have to be adapted to support various formats (in particular mp3)

@auroracramer auroracramer added the enhancement New feature or request label Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants