[aubio-user] Phase vocoder: Custom bands

Paul Brossier piem at aubio.org
Tue Nov 21 12:48:48 CET 2017


On 11/21/2017 10:09 AM, Thomas Fischer wrote:
> Dear Paul,
> 
> thank you for your reply and for your helpful suggestion - this looks
> very promising.
> Unfortunately, I haven't been able to get this to work. Please see my
> attempt below. It returns this error:
> 
> spectrum.norm *= spec_weight
> ValueError: operands could not be broadcast together with shapes (257,)
> (2048,) (257,)

Hello Thomas,

As the error message indicates, both vectors should have the same size.
If you create a phase vocoder with size N, the norm vector will be N/2+1
long.

Here you used win_s = 512, so spec_weight should be 257 long.

Best, Paul

> 
> What am I doing wrong?
> 
> Thanks a lot and best regards,
> Tom
> 
>>>>
> 
> #! /usr/bin/env python
> 
> import sys
> from aubio import source, sink, pvoc
> from numpy import arange, exp, zeros, ones, concatenate
> 
> if len(sys.argv) < 2:
>     print('usage: %s <inputfile> <outputfile>' % sys.argv[0])
>     sys.exit(1)
> 
> samplerate = 0 
> if len(sys.argv) > 3: samplerate = int(sys.argv[3])
> f = source(sys.argv[1], samplerate, 256)
> samplerate = f.samplerate
> g = sink(sys.argv[2], samplerate)
> 
> win_s = 512 # fft size
> hop_s = win_s // 2 # hop size
> pv = pvoc(win_s, hop_s) # phase vocoder
> 
> # spectral weighting vector
> spec_weight = concatenate ( [
>     zeros(88),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(165),
>     ones(25),
>     zeros(35)
>      ])
> 
> total_frames, read = 0, hop_s
> while read:
>     # get new samples
>     samples, read = f()
>     # compute spectrum
>     spectrum = pv(samples)
>     # apply weight to spectral amplitudes
>     spectrum.norm *= spec_weight
>     # resynthesise modified samples
>     new_samples = pv.rdo(spectrum)
>     # write to output
>     g(new_samples, read)
>     total_frames += read
> 
>     
> 
> 
> 
> _______________________________________________
> aubio-user mailing list
> aubio-user at aubio.org
> https://lists.aubio.org/listinfo/aubio-user
> 



More information about the aubio-user mailing list