Exemple #1
0
def wavgen_magphase(gen_dir, file_id_list, cfg, logger):

    # Import MagPhase and libraries:
    sys.path.append(cfg.magphase_bindir)
    import libutils as lu
    import libaudio as la
    import magphase as mp

    nfiles = len(file_id_list)
    for nxf in xrange(nfiles):
        filename_token = file_id_list[nxf]
        logger.info('Creating waveform for %4d of %4d: %s' %
                    (nxf + 1, nfiles, filename_token))

        for pf_type in cfg.magphase_pf_type:
            gen_wav_dir = os.path.join(gen_dir + '_wav_pf_' + pf_type)
            lu.mkdir(gen_wav_dir)
            mp.synthesis_from_acoustic_modelling(
                gen_dir,
                filename_token,
                gen_wav_dir,
                cfg.mag_dim,
                cfg.real_dim,
                cfg.sr,
                pf_type=pf_type,
                b_const_rate=cfg.magphase_const_rate)

    return
def synthesis(in_feats_dir, filename_token, out_syn_dir, nbins_mel,
              nbins_phase, fs, b_postfilter):
    print('\nGenerating wavefile: ' + filename_token +
          '................................')
    mp.synthesis_from_acoustic_modelling(in_feats_dir, filename_token,
                                         out_syn_dir, nbins_mel, nbins_phase,
                                         fs, b_postfilter)
    return
Exemple #3
0
def wavgen_magphase(gen_dir, file_id_list, cfg, logger):

    # Import MagPhase and libraries:
    sys.path.append(cfg.magphase_bindir)
    import libutils as lu
    import libaudio as la
    import magphase as mp

    nfiles = len(file_id_list)
    for nxf in xrange(nfiles):
        filename_token = file_id_list[nxf]
        logger.info('Creating waveform for %4d of %4d: %s' %
                    (nxf + 1, nfiles, filename_token))

        # Post-Filter:
        if cfg.do_post_filtering and not cfg.use_magphase_pf:

            mcep_file = os.path.join(gen_dir, filename_token + '.mcep')
            mcep_file_pf = os.path.join(gen_dir, filename_token + '_pf.mcep')
            mag_file = os.path.join(gen_dir, filename_token + '.mag')

            # Mag to Mcep:
            m_mag_mel_log = lu.read_binfile(mag_file, dim=cfg.mag_dim)
            m_mcep = la.rceps(m_mag_mel_log, in_type='log', out_type='compact')
            lu.write_binfile(m_mcep, mcep_file)

            # Apply post-filter:
            post_filter(mcep_file, mcep_file_pf, cfg.mag_dim, cfg.pf_coef,
                        cfg.fw_alpha, cfg.co_coef, cfg.fl, gen_dir, cfg)

            # Mcep to Mag:
            m_mcep_pf = lu.read_binfile(mcep_file_pf, dim=cfg.mag_dim)
            m_mag_mel_log_pf = la.mcep_to_sp_cosmat(m_mcep_pf,
                                                    cfg.mag_dim,
                                                    alpha=0.0,
                                                    out_type='log')

            # Protection agains possible nans:
            m_mag_mel_log_pf[np.isnan(m_mag_mel_log_pf)] = la.MAGIC

            # Saving to file:
            lu.write_binfile(m_mag_mel_log_pf, mag_file)

            # Removing temp files:
            os.remove(mcep_file)
            os.remove(mcep_file_pf)

        # Synthesis:
        mp.synthesis_from_acoustic_modelling(
            gen_dir,
            filename_token,
            gen_dir,
            cfg.mag_dim,
            cfg.real_dim,
            cfg.sr,
            b_postfilter=(cfg.do_post_filtering and cfg.use_magphase_pf))

    return
def synthesis(in_feats_dir, filename_token, out_syn_dir, mag_dim, phase_dim,
              fs, pf_type):
    mp.synthesis_from_acoustic_modelling(in_feats_dir,
                                         filename_token,
                                         out_syn_dir,
                                         mag_dim,
                                         phase_dim,
                                         fs,
                                         pf_type=pf_type,
                                         b_const_rate=False)
    return
Exemple #5
0
def wavgen_magphase(gen_dir, file_id_list, cfg, logger):

    # Import MagPhase and libraries:
    sys.path.append(cfg.magphase_bindir)
    import libutils as lu
    import libaudio as la
    import magphase as mp

    nfiles = len(file_id_list)
    for nxf in xrange(nfiles):
        filename_token = file_id_list[nxf]
        logger.info('Creating waveform for %4d of %4d: %s' % (nxf+1, nfiles, filename_token))

        for pf_type in cfg.magphase_pf_type:
            gen_wav_dir = os.path.join(gen_dir + '_wav_pf_' + pf_type)
            lu.mkdir(gen_wav_dir)
            mp.synthesis_from_acoustic_modelling(gen_dir, filename_token, gen_wav_dir, cfg.mag_dim, cfg.real_dim,
                                                            cfg.sr, pf_type=pf_type, b_const_rate=cfg.magphase_const_rate)

    return
Exemple #6
0
#!/usr/bin/python2
import sys, os
sys.path.append(os.environ['MAGPHASE'])
import magphase as mp
import libaudio as la
import libutils as lu
from os import path
from argparse import ArgumentParser

if __name__ == '__main__':
    p = ArgumentParser()
    p.add_argument('-s', '--sentence', dest='sentence', required=True)
    p.add_argument('-o', '--outdir', dest='outdir', required=True)
    p.add_argument('-m', '--magdim', dest='magdim', type=int, required=True)
    p.add_argument('-p', '--phadim', dest='phadim', type=int, required=True)
    p.add_argument('-f', '--filter', dest='filter', default='no')
    p.add_argument('-v', '--variable', dest='const_rate', action='store_false')
    a = p.parse_args()

    mp.synthesis_from_acoustic_modelling(a.outdir,
                                         a.sentence,
                                         a.outdir,
                                         a.magdim,
                                         a.phadim,
                                         48000,
                                         pf_type=a.filter,
                                         b_const_rate=a.const_rate)
def synthesis(in_feats_dir, filename_token, out_syn_dir, nbins_mel, nbins_phase, fs, b_postfilter):
    print('\nGenerating wavefile: ' + filename_token + '................................')
    mp.synthesis_from_acoustic_modelling(in_feats_dir, filename_token, out_syn_dir, nbins_mel, nbins_phase, fs, b_postfilter)
    return