neuro-team-femto / cleese

Combinatorial Expressive Speech Engine
MIT License
42 stars 10 forks source link

Added utility for extracting spectral envelope #30

Closed jjau closed 5 months ago

jjau commented 5 months ago

What

Added a utility function for extracting a sound signal's spectral envelope

Why

Visualizing results from EQ transforms in PhaseVocoder (as e.g. done in Ponsot JASA 2018) requires to extract the signal's spectral enveloppe. This currently isn't a utility offered in cleese, and there is no easy alternative in the community (e.g. librosa etc.)

How

Added a new function in engines/phase_vocoder/utils.py and linked it as a static method in the PhaseVocoder class. The function implements LPC spectral envelope estimation (code by @pmblanc) using scipy.signal and scipy.linalg libraries.

Testing

from cleese_stim.engines import PhaseVocoder

wav, sr, fmat =  PhaseVocoder.wav_read('docs/docs/tutorials/sounds/female_a.wav')
freqs, env = PhaseVocoder.extract_spectral_env(wav, sr)

plt.figure(figsize=(20,5))
plt.plot(freqs, env)
plt.xscale('log')