From 32b9755cbeecf94b7aed3bcab937fa492e91fc62 Mon Sep 17 00:00:00 2001 From: babysor00 Date: Sun, 12 Sep 2021 17:33:39 +0800 Subject: [PATCH] Refactor folder structure --- toolbox/__init__.py | 11 ++--------- {hifigan => vocoder/hifigan}/config_16k_.json | 0 {hifigan => vocoder/hifigan}/env.py | 0 {hifigan => vocoder/hifigan}/inference.py | 11 ++++------- {hifigan => vocoder/hifigan}/meldataset.py | 0 {hifigan => vocoder/hifigan}/models.py | 2 +- {hifigan => vocoder/hifigan}/utils.py | 0 vocoder/{ => wavernn}/audio.py | 2 +- vocoder/{ => wavernn}/gen_wavernn.py | 4 ++-- vocoder/{ => wavernn}/hparams.py | 0 vocoder/{ => wavernn}/inference.py | 4 ++-- vocoder/{ => wavernn}/models/deepmind_version.py | 0 vocoder/{ => wavernn}/models/fatchord_version.py | 2 +- vocoder/{ => wavernn}/train.py | 6 +++--- vocoder_train.py | 2 +- 15 files changed, 17 insertions(+), 27 deletions(-) rename {hifigan => vocoder/hifigan}/config_16k_.json (100%) rename {hifigan => vocoder/hifigan}/env.py (100%) rename {hifigan => vocoder/hifigan}/inference.py (86%) rename {hifigan => vocoder/hifigan}/meldataset.py (100%) rename {hifigan => vocoder/hifigan}/models.py (99%) rename {hifigan => vocoder/hifigan}/utils.py (100%) rename vocoder/{ => wavernn}/audio.py (98%) rename vocoder/{ => wavernn}/gen_wavernn.py (90%) rename vocoder/{ => wavernn}/hparams.py (100%) rename vocoder/{ => wavernn}/inference.py (94%) rename vocoder/{ => wavernn}/models/deepmind_version.py (100%) rename vocoder/{ => wavernn}/models/fatchord_version.py (99%) rename vocoder/{ => wavernn}/train.py (96%) diff --git a/toolbox/__init__.py b/toolbox/__init__.py index 090c961..9f7c74e 100644 --- a/toolbox/__init__.py +++ b/toolbox/__init__.py @@ -1,8 +1,8 @@ from toolbox.ui import UI from encoder import inference as encoder from synthesizer.inference import Synthesizer -from vocoder import inference as rnn_vocoder -from hifigan import inference as gan_vocoder +from vocoder.wavernn import inference as rnn_vocoder +from vocoder.hifigan import inference as gan_vocoder from pathlib import Path from time import perf_counter as timer from toolbox.utterance import Utterance @@ -50,13 +50,6 @@ MAX_WAVES = 15 class Toolbox: def __init__(self, datasets_root, enc_models_dir, syn_models_dir, voc_models_dir, seed, no_mp3_support): - if not no_mp3_support: - try: - librosa.load("samples/6829_00000.mp3") - except NoBackendError: - print("Librosa will be unable to open mp3 files if additional software is not installed.\n" - "Please install ffmpeg or add the '--no_mp3_support' option to proceed without support for mp3 files.") - exit(-1) self.no_mp3_support = no_mp3_support sys.excepthook = self.excepthook self.datasets_root = datasets_root diff --git a/hifigan/config_16k_.json b/vocoder/hifigan/config_16k_.json similarity index 100% rename from hifigan/config_16k_.json rename to vocoder/hifigan/config_16k_.json diff --git a/hifigan/env.py b/vocoder/hifigan/env.py similarity index 100% rename from hifigan/env.py rename to vocoder/hifigan/env.py diff --git a/hifigan/inference.py b/vocoder/hifigan/inference.py similarity index 86% rename from hifigan/inference.py rename to vocoder/hifigan/inference.py index ff48c79..0912726 100644 --- a/hifigan/inference.py +++ b/vocoder/hifigan/inference.py @@ -1,15 +1,12 @@ from __future__ import absolute_import, division, print_function, unicode_literals -import glob import os -import argparse import json import torch -import numpy as np from scipy.io.wavfile import write -from hifigan.env import AttrDict -from hifigan.meldataset import mel_spectrogram, MAX_WAV_VALUE, load_wav -from hifigan.models import Generator +from vocoder.hifigan.env import AttrDict +from vocoder.hifigan.meldataset import mel_spectrogram, MAX_WAV_VALUE, load_wav +from vocoder.hifigan.models import Generator import soundfile as sf @@ -31,7 +28,7 @@ def load_model(weights_fpath, verbose=True): if verbose: print("Building hifigan") - with open("./hifigan/config_16k_.json") as f: + with open("./vocoder/hifigan/config_16k_.json") as f: data = f.read() json_config = json.loads(data) h = AttrDict(json_config) diff --git a/hifigan/meldataset.py b/vocoder/hifigan/meldataset.py similarity index 100% rename from hifigan/meldataset.py rename to vocoder/hifigan/meldataset.py diff --git a/hifigan/models.py b/vocoder/hifigan/models.py similarity index 99% rename from hifigan/models.py rename to vocoder/hifigan/models.py index 725de4e..9caf382 100644 --- a/hifigan/models.py +++ b/vocoder/hifigan/models.py @@ -3,7 +3,7 @@ import torch.nn.functional as F import torch.nn as nn from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm -from hifigan.utils import init_weights, get_padding +from vocoder.hifigan.utils import init_weights, get_padding LRELU_SLOPE = 0.1 diff --git a/hifigan/utils.py b/vocoder/hifigan/utils.py similarity index 100% rename from hifigan/utils.py rename to vocoder/hifigan/utils.py diff --git a/vocoder/audio.py b/vocoder/wavernn/audio.py similarity index 98% rename from vocoder/audio.py rename to vocoder/wavernn/audio.py index 1163962..bec9768 100644 --- a/vocoder/audio.py +++ b/vocoder/wavernn/audio.py @@ -1,7 +1,7 @@ import math import numpy as np import librosa -import vocoder.hparams as hp +import vocoder.wavernn.hparams as hp from scipy.signal import lfilter import soundfile as sf diff --git a/vocoder/gen_wavernn.py b/vocoder/wavernn/gen_wavernn.py similarity index 90% rename from vocoder/gen_wavernn.py rename to vocoder/wavernn/gen_wavernn.py index 2036737..abda3eb 100644 --- a/vocoder/gen_wavernn.py +++ b/vocoder/wavernn/gen_wavernn.py @@ -1,5 +1,5 @@ -from vocoder.models.fatchord_version import WaveRNN -from vocoder.audio import * +from vocoder.wavernn.models.fatchord_version import WaveRNN +from vocoder.wavernn.audio import * def gen_testset(model: WaveRNN, test_set, samples, batched, target, overlap, save_path): diff --git a/vocoder/hparams.py b/vocoder/wavernn/hparams.py similarity index 100% rename from vocoder/hparams.py rename to vocoder/wavernn/hparams.py diff --git a/vocoder/inference.py b/vocoder/wavernn/inference.py similarity index 94% rename from vocoder/inference.py rename to vocoder/wavernn/inference.py index 7e54684..285ed6d 100644 --- a/vocoder/inference.py +++ b/vocoder/wavernn/inference.py @@ -1,5 +1,5 @@ -from vocoder.models.fatchord_version import WaveRNN -from vocoder import hparams as hp +from vocoder.wavernn.models.fatchord_version import WaveRNN +from vocoder.wavernn import hparams as hp import torch diff --git a/vocoder/models/deepmind_version.py b/vocoder/wavernn/models/deepmind_version.py similarity index 100% rename from vocoder/models/deepmind_version.py rename to vocoder/wavernn/models/deepmind_version.py diff --git a/vocoder/models/fatchord_version.py b/vocoder/wavernn/models/fatchord_version.py similarity index 99% rename from vocoder/models/fatchord_version.py rename to vocoder/wavernn/models/fatchord_version.py index 70ef1e3..6413a92 100644 --- a/vocoder/models/fatchord_version.py +++ b/vocoder/wavernn/models/fatchord_version.py @@ -3,7 +3,7 @@ import torch.nn as nn import torch.nn.functional as F from vocoder.distribution import sample_from_discretized_mix_logistic from vocoder.display import * -from vocoder.audio import * +from vocoder.wavernn.audio import * class ResBlock(nn.Module): diff --git a/vocoder/train.py b/vocoder/wavernn/train.py similarity index 96% rename from vocoder/train.py rename to vocoder/wavernn/train.py index 4912469..44e0929 100644 --- a/vocoder/train.py +++ b/vocoder/wavernn/train.py @@ -1,13 +1,13 @@ -from vocoder.models.fatchord_version import WaveRNN +from vocoder.wavernn.models.fatchord_version import WaveRNN from vocoder.vocoder_dataset import VocoderDataset, collate_vocoder from vocoder.distribution import discretized_mix_logistic_loss from vocoder.display import stream, simple_table -from vocoder.gen_wavernn import gen_testset +from vocoder.wavernn.gen_wavernn import gen_testset from torch.utils.data import DataLoader from pathlib import Path from torch import optim import torch.nn.functional as F -import vocoder.hparams as hp +import vocoder.wavernn.hparams as hp import numpy as np import time import torch diff --git a/vocoder_train.py b/vocoder_train.py index d712ffa..224a65e 100644 --- a/vocoder_train.py +++ b/vocoder_train.py @@ -1,5 +1,5 @@ from utils.argutils import print_args -from vocoder.train import train +from vocoder.wavernn.train import train from pathlib import Path import argparse