import os.path

    root, ext = os.path.splitext(args[0])
    if options.method == 0:
        ss = SpectralSubtruction(options.winsize, window)
        outfname = "%s_ss%s" % (root, ext)
    elif options.method == 1:
        ss = MMSE_STSA(options.winsize, window)
        outfname = "%s_mmse%s" % (root, ext)
    elif options.method == 2:
        ss = MMSE_LogSTSA(options.winsize, window, alpha=0.99)
        outfname = "%s_lmmse%s" % (root, ext)
    elif options.method == 3:
        ss = JointMap(options.winsize, window, alpha=0.99)
        outfname = "%s_jm%s" % (root, ext)

    if params[0] == 1:
        write(
            params,
            noise_reduction(signal, params, options.winsize, window, ss,
                            options.ntime))
    elif params[0] == 2:
        l, r = separate_channels(signal)
        write(
            params,
            uniting_channles(
                noise_reduction(l, params, options.winsize, window, ss,
                                options.ntime),
                noise_reduction(r, params, options.winsize, window, ss,
                                options.ntime)))
Esempio n. 2
0
    if len(args) != 1:
        parser.print_help()
        exit(2)

    fname = args[0]
    signal, params = read(fname, options.winsize)

    window = sp.hanning(options.winsize)
    import os.path
    
    root, ext = os.path.splitext(args[0])
    if options.method == 0:
        ss = SpectralSubtruction(options.winsize, window, ratio=options.ratio, coefficient=options.sscoefficient)
        outfname = "%s_ss%s" % (root, ext)
    elif options.method == 1:
        ss = MMSE_STSA(options.winsize, window, ratio=options.ratio, constant=options.constant, alpha=options.alpha)
        outfname = "%s_mmse%s" % (root, ext)
    elif options.method == 2:
        ss = MMSE_LogSTSA(options.winsize, window, ratio=options.ratio, alpha=options.alpha, constant=options.constant)
        outfname = "%s_lmmse%s" % (root, ext)
    elif options.method == 3:
        ss = JointMap(options.winsize, window, alpha=options.alpha, ratio=options.ratio, constant=options.constant)
        outfname = "%s_jm%s" % (root, ext)

    if params[0] == 1:
        write(params, noise_reduction(signal, params, options. winsize, window, ss, options.ntime))
    elif params[0] == 2:
        l, r = separate_channels(signal)
        write(params, uniting_channles(noise_reduction(l, params, options.winsize, window, ss, options.ntime),
                                       noise_reduction(r, params, options.winsize, window, ss, options.ntime)))
Esempio n. 3
0
    usage = "%python vad [-t THREASHOLD] [-w WINSIZE] [- s NOISETIME(ms)] "\
            "INPUTFILE \n if INPUTFILE is \"-\", read wave data from stdin"
    parser = optparse.OptionParser(usage=usage)

    parser.add_option("-w", type="int", dest="winsize", default=WINSIZE)
    parser.add_option("-t", type="int", dest="th", default=10)
    parser.add_option("-s", type="int", dest="ntime", default=300)

    (options, args) = parser.parse_args()
    windowsize = options.winsize

    fname = args[0]
    signal, params = read(fname, options.winsize)
    window = np.hanning(windowsize)
    ntime = options.ntime

    if params[0] == 1:
        ltsd = LTSD(windowsize, window, 5, lambda0=options.th)
        res, ltsds = ltsd.compute_with_noise(signal,
                                             signal[0:windowsize*int(params[2]/float(windowsize)/(1000.0/ntime))])
        write(params, vad(res, signal, windowsize, window))
    elif params[0] == 2:
        noise_sec = windowsize*int(params[2]/float(windowsize)/(1000.0/ntime))
        l, r = separate_channels(signal)
        ltsd_l = LTSD(windowsize, window, 5, lambda0=options.th)
        ltsd_r = LTSD(windowsize, window, 5, lambda0=options.th)
        l_out = vad(ltsd_l.compute_without_noise(l, noise_sec)[0], l, windowsize, window)
        r_out = vad(ltsd_r.compute_without_noise(r, noise_sec)[0], r, windowsize, window)
        out = uniting_channles(l_out, r_out)
        write(params, out)
Esempio n. 4
0
    if len(args)!=2:
        parser.print_help()
        exit(2)

    kl = KaraokeFileLoader(options.winsize*2)

    ssignal,ksignal,params = kl.load_file(args[0],args[1])
    ssignal_l,ssignal_r = separate_channels(ssignal)
    ksignal_l,ksignal_r = separate_channels(ksignal)

    window = sp.hanning(options.winsize)

    if options.method==0:
        method = SpectralSubtruction(options.winsize,window)
    elif options.method==1:
        method = MMSE_STSA(options.winsize,window)
    elif options.method==2:
        method = MMSE_LogSTSA(options.winsize,window,alpha=0.99)
    elif options.method==3:
        method = JointMap(options.winsize,window,alpha=0.99)

    sig_out_l = subtruction(ssignal_l,ksignal_l,window,options.winsize,method)
    sig_out_r = subtruction(ssignal_r,ksignal_r,window,options.winsize,method)

    sig_out_l[sp.isnan(sig_out_l)+sp.isinf(sig_out_l)]=0.0
    sig_out_r[sp.isnan(sig_out_r)+sp.isinf(sig_out_r)]=0.0


    result = uniting_channles(sig_out_l, sig_out_r)
    write(params, result)
Esempio n. 5
0
    (options, args) = parser.parse_args()
    windowsize = options.winsize

    fname = args[0]
    signal, params = read(fname, options.winsize)
    window = sp.hanning(windowsize)
    ntime = options.ntime

    if params[0] == 1:
        ltsd = LTSD(windowsize, window, 5, lambda0=options.th)
        res, ltsds = ltsd.compute_with_noise(
            signal, signal[0:windowsize * int(params[2] / float(windowsize) /
                                              (1000.0 / ntime))])  #maybe 300ms
        write(params, vad(res, signal, windowsize, window))
    elif params[0] == 2:
        l, r = separate_channels(signal)
        ltsd_l = LTSD(windowsize, window, 5, lambda0=options.th)
        ltsd_r = LTSD(windowsize, window, 5, lambda0=options.th)
        out = uniting_channles(
            vad(
                ltsd_l.compute_with_noise(
                    l, l[0:windowsize * int(params[2] / float(windowsize) /
                                            (1000.0 / ntime))])[0], l,
                windowsize, window),
            vad(
                ltsd_r.compute_with_noise(
                    r, r[0:windowsize * int(params[2] / float(windowsize) /
                                            (1000.0 / ntime))])[0], r,
                windowsize, window))
        write(params, out)