示例#1
0
import sys
import pickle
import numpy as np
import soundfile as sf
import librosa
from scipy import signal
from librosa.filters import mel
from numpy.random import RandomState
from pysptk import sptk
from utils import butter_highpass
from utils import speaker_normalization
from utils import pySTFT

mel_basis = mel(22050, 1024, fmin=55, fmax=7600, n_mels=80).T  # 원래 fmin=90
min_level = np.exp(-100 / 20 * np.log(10))
b, a = butter_highpass(30, 22050, order=5)

spk2gen = pickle.load(open('assets/spk2gen.pkl', "rb"))

# Used speakers
females = [
    '001', '005', '013', '017', '023', '024', '030', '032', '036', '037'
]
males = ['002', '003', '004', '006', '007', '008', '009', '010', '011', '012']
used_spks = females + males

# Modify as needed
rootDir = '/hd0/dataset/audiobook'
targetDir_f0 = '/hd0/speechsplit/preprocessed/raptf0'
targetDir = '/hd0/speechsplit/preprocessed/spmel'
示例#2
0
import os

import torch
tr = torch

device = tr.device("cuda") if tr.cuda.is_available() else tr.device("cpu")
print(device)
encoders = GetCodes(hparams).eval().to(device)
g_checkpoint = torch.load('assets/660000-G.ckpt',
                          map_location=lambda storage, loc: storage)
encoders.load_state_dict(g_checkpoint['model'])
print("Succesfully loaded")

mel_basis = mel(16000, 1024, fmin=90, fmax=7600, n_mels=80).T
min_level = np.exp(-100 / 20 * np.log(10))
b, a = butter_highpass(30, 16000, order=5)

# Get the codes for each utterance and save the corresponding codes in a large pickle
# List(Dict{'dys', 'ctrl'}) - numpy ndarray in the value part of the dict

src_path = "/home/terbed/PROJECTS/DYS/DATA/UAS-subset/M05"
trg_path = "/home/terbed/PROJECTS/DYS/DATA/UAS-subset/CM10"
lo, hi = 50, 250

src_speaker = src_path.split("/")[-1]
trg_speaker = trg_path.split("/")[-1]

_, _, fnames = next(os.walk(src_path))
database = []

示例#3
0
from numpy.random import RandomState
from pysptk import sptk
import librosa
from utils import butter_highpass
from utils import speaker_normalization
from utils import pySTFT
from hparams import hparams

mel_basis = mel(hparams.sample_rate,
                hparams.fft_size,
                fmin=hparams.fmin,
                fmax=hparams.fmax,
                n_mels=hparams.num_mels).T
min_level = np.exp(hparams.min_level_db / 20 * np.log(10))
b, a = butter_highpass(hparams.cutoff,
                       hparams.sample_rate,
                       order=hparams.order)


def build_from_path(hparams,
                    in_dir,
                    out_dir,
                    spk_emb_path,
                    spk2gen_path,
                    num_workers=16):

    executor = ProcessPoolExecutor(max_workers=num_workers)

    # load spk paths
    if hparams.used_spks is not None:
        spk_paths = [