|
1 | 1 | from librosa.effects import hpss |
| 2 | +import numpy as np |
2 | 3 | from .pvtsm import phase_vocoder |
3 | 4 | from .olatsm import ola |
| 5 | +from .utils import _validate_audio |
4 | 6 |
|
5 | 7 |
|
6 | 8 | def hptsm(x, s, hp_kernel_size=31, hp_power=2.0, hp_mask=False, hp_margin=1.0, |
@@ -32,9 +34,16 @@ def hptsm(x, s, hp_kernel_size=31, hp_power=2.0, hp_mask=False, hp_margin=1.0, |
32 | 34 | y : numpy.ndarray [shape=(channel, num_samples) or (num_samples)] |
33 | 35 | the modified output audio sequence. |
34 | 36 | """ |
35 | | - |
36 | | - x_harm, x_perc = hpss(x, kernel_size=hp_kernel_size, power=hp_power, |
37 | | - mask=hp_mask, margin=hp_margin) |
| 37 | + x = _validate_audio(x) |
| 38 | + x_harm = np.zeros(x.shape) |
| 39 | + x_perc = np.zeros(x.shape) |
| 40 | + |
| 41 | + for c, x_chan in enumerate(x): |
| 42 | + x_harm_chan, x_perc_chan = hpss(x_chan, kernel_size=hp_kernel_size, |
| 43 | + power=hp_power, mask=hp_mask, |
| 44 | + margin=hp_margin) |
| 45 | + x_harm[c, :] = x_harm_chan |
| 46 | + x_perc[c, :] = x_perc_chan |
38 | 47 |
|
39 | 48 | y_harm = phase_vocoder(x_harm, s, win_type=pv_win_type, |
40 | 49 | win_size=pv_win_size, syn_hop_size=pv_syn_hop_size, |
|
0 commit comments