[aubio-user] Phase vocoder: Custom bands

Thomas Fischer Thomas.Fischer at xjtlu.edu.cn
Tue Nov 21 10:09:17 CET 2017


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,)

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



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.aubio.org/pipermail/aubio-user/attachments/20171121/4d118884/attachment.html>


More information about the aubio-user mailing list