rosa_test.py 399 B

1234567891011
  1. import librosa
  2. import soundfile as sf
  3. import numpy as np
  4. y, sr = librosa.load('c:/tmp/source.wav', sr=44100) # y is a numpy array of the wav file, sr = sample rate
  5. y_shifted = librosa.effects.pitch_shift(y, sr, n_steps=0) # shifted by 4 half steps
  6. #librosa.write_wav('c:/tmp/test.wav', y_shifted, sr)
  7. # Write out audio as 24bit PCM WAV
  8. sf.write('c:/tmp/test.wav', y_shifted, sr, subtype='PCM_24')