lyrebird-voice-changer / lyrebird

🦜 Simple and powerful voice changer for Linux, written with Python & GTK
MIT License
1.83k stars 115 forks source link

Migrate to using librosa and librubberband for formant shifting #37

Closed megabytesofrem closed 3 years ago

megabytesofrem commented 4 years ago

Migrate to using librosa and librubberband for formant shifting. This would make the male and most importantly female voices, much more accurate and allow even more vocal flexibility in the future, since we could easily implement phaser effects and vocoders using librosa later on when we have the groundwork for a low-level streaming solution, rather than relying on sox.

I've played around, and it seems to be possible to use librubberband from Python and read data from a wave file (called bad.wav), apply a pitch shift effect with formant shifting and write it to "good.wav".

import soundfile as sf
import pyrubberband as pyrb

y, sr = sf.read('/home/char/bad.wav')
shifted = pyrb.pitch_shift(y, sr, n_steps=2.4)
sf.write('good.wav', shifted, sr)

The code to achieve this for a wave file is above, however in order to make this realtime we will need to do something like the following.

  1. Read from the microphone input, and stream into a buffer/numpy array(?)
  2. Process the buffer whenever new data is added to it, and apply the pitch shift effect
  3. Write this new buffer out to a Pulse null output, like before in sox only this time writing the numpy array instead of piping directly from sox
ghost commented 4 years ago

@chxrlt What's the official status now? Still using rubberband and other DSP libs?

ghost commented 3 years ago

C rewrite is the future of Lyrebird :sunglasses: