diff --git a/.gitignore b/.gitignore index 5302980..a84d82b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,8 +14,8 @@ *.bcf *.toc *.sh -*/saved_models -!vocoder/saved_models/pretrained/** -!encoder/saved_models/pretrained.pt +data/ckpt +!data/ckpt/vocoder/pretrained/** +!data/ckpt/encoder/pretrained.pt wavs log \ No newline at end of file diff --git a/archived_untest_files/demo_cli.py b/archived_untest_files/demo_cli.py index c7309e8..612ef8a 100644 --- a/archived_untest_files/demo_cli.py +++ b/archived_untest_files/demo_cli.py @@ -1,9 +1,9 @@ -from encoder.params_model import model_embedding_size as speaker_embedding_size +from models.encoder.params_model import model_embedding_size as speaker_embedding_size from utils.argutils import print_args from utils.modelutils import check_model_paths -from synthesizer.inference import Synthesizer -from encoder import inference as encoder -from vocoder import inference as vocoder +from models.synthesizer.inference import Synthesizer +from models.encoder import inference as encoder +from models.vocoder import inference as vocoder from pathlib import Path import numpy as np import soundfile as sf diff --git a/encoder/__init__.py b/control/__init__.py similarity index 100% rename from encoder/__init__.py rename to control/__init__.py diff --git a/encoder_preprocess.py b/control/cli/encoder_preprocess.py similarity index 93% rename from encoder_preprocess.py rename to control/cli/encoder_preprocess.py index 853c6cb..9090044 100644 --- a/encoder_preprocess.py +++ b/control/cli/encoder_preprocess.py @@ -1,7 +1,10 @@ -from encoder.preprocess import preprocess_librispeech, preprocess_voxceleb1, preprocess_voxceleb2, preprocess_aidatatang_200zh -from utils.argutils import print_args -from pathlib import Path import argparse +from pathlib import Path + +from models.encoder.preprocess import (preprocess_aidatatang_200zh, + preprocess_librispeech, preprocess_voxceleb1, + preprocess_voxceleb2) +from utils.argutils import print_args if __name__ == "__main__": class MyFormatter(argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter): diff --git a/encoder_train.py b/control/cli/encoder_train.py similarity index 98% rename from encoder_train.py rename to control/cli/encoder_train.py index b8740a8..8756925 100644 --- a/encoder_train.py +++ b/control/cli/encoder_train.py @@ -1,5 +1,5 @@ from utils.argutils import print_args -from encoder.train import train +from models.encoder.train import train from pathlib import Path import argparse diff --git a/ppg2mel_train.py b/control/cli/ppg2mel_train.py similarity index 97% rename from ppg2mel_train.py rename to control/cli/ppg2mel_train.py index 5a6a06c..557bc26 100644 --- a/ppg2mel_train.py +++ b/control/cli/ppg2mel_train.py @@ -3,7 +3,7 @@ import torch import argparse import numpy as np from utils.load_yaml import HpsYaml -from ppg2mel.train.train_linglf02mel_seq2seq_oneshotvc import Solver +from models.ppg2mel.train.train_linglf02mel_seq2seq_oneshotvc import Solver # For reproducibility, comment these may speed up training torch.backends.cudnn.deterministic = True diff --git a/pre4ppg.py b/control/cli/pre4ppg.py similarity index 97% rename from pre4ppg.py rename to control/cli/pre4ppg.py index fcfa0fa..a3b03a1 100644 --- a/pre4ppg.py +++ b/control/cli/pre4ppg.py @@ -1,7 +1,7 @@ from pathlib import Path import argparse -from ppg2mel.preprocess import preprocess_dataset +from models.ppg2mel.preprocess import preprocess_dataset from pathlib import Path import argparse diff --git a/synthesizer_preprocess_audio.py b/control/cli/synthesizer_preprocess_audio.py similarity index 96% rename from synthesizer_preprocess_audio.py rename to control/cli/synthesizer_preprocess_audio.py index 51d92f9..12270fe 100644 --- a/synthesizer_preprocess_audio.py +++ b/control/cli/synthesizer_preprocess_audio.py @@ -1,5 +1,5 @@ -from synthesizer.preprocess import preprocess_dataset -from synthesizer.hparams import hparams +from models.synthesizer.preprocess import preprocess_dataset +from models.synthesizer.hparams import hparams from utils.argutils import print_args from pathlib import Path import argparse diff --git a/synthesizer_preprocess_embeds.py b/control/cli/synthesizer_preprocess_embeds.py similarity index 95% rename from synthesizer_preprocess_embeds.py rename to control/cli/synthesizer_preprocess_embeds.py index 7276626..1fea8bc 100644 --- a/synthesizer_preprocess_embeds.py +++ b/control/cli/synthesizer_preprocess_embeds.py @@ -1,4 +1,4 @@ -from synthesizer.preprocess import create_embeddings +from models.synthesizer.preprocess import create_embeddings from utils.argutils import print_args from pathlib import Path import argparse diff --git a/synthesizer_train.py b/control/cli/synthesizer_train.py similarity index 95% rename from synthesizer_train.py rename to control/cli/synthesizer_train.py index 0f0b598..8fb41ae 100644 --- a/synthesizer_train.py +++ b/control/cli/synthesizer_train.py @@ -1,5 +1,5 @@ -from synthesizer.hparams import hparams -from synthesizer.train import train +from models.synthesizer.hparams import hparams +from models.synthesizer.train import train from utils.argutils import print_args import argparse diff --git a/vocoder_preprocess.py b/control/cli/vocoder_preprocess.py similarity index 96% rename from vocoder_preprocess.py rename to control/cli/vocoder_preprocess.py index 95f9e5a..eb89ea0 100644 --- a/vocoder_preprocess.py +++ b/control/cli/vocoder_preprocess.py @@ -1,5 +1,5 @@ -from synthesizer.synthesize import run_synthesis -from synthesizer.hparams import hparams +from models.synthesizer.synthesize import run_synthesis +from models.synthesizer.hparams import hparams from utils.argutils import print_args import argparse import os diff --git a/vocoder_train.py b/control/cli/vocoder_train.py similarity index 96% rename from vocoder_train.py rename to control/cli/vocoder_train.py index f618ee0..07e93db 100644 --- a/vocoder_train.py +++ b/control/cli/vocoder_train.py @@ -1,7 +1,7 @@ from utils.argutils import print_args -from vocoder.wavernn.train import train -from vocoder.hifigan.train import train as train_hifigan -from vocoder.fregan.train import train as train_fregan +from models.vocoder.wavernn.train import train +from models.vocoder.hifigan.train import train as train_hifigan +from models.vocoder.fregan.train import train as train_fregan from utils.util import AttrDict from pathlib import Path import argparse diff --git a/mkgui/__init__.py b/control/mkgui/__init__.py similarity index 100% rename from mkgui/__init__.py rename to control/mkgui/__init__.py diff --git a/mkgui/app.py b/control/mkgui/app.py similarity index 91% rename from mkgui/app.py rename to control/mkgui/app.py index d4364aa..693b168 100644 --- a/mkgui/app.py +++ b/control/mkgui/app.py @@ -2,22 +2,22 @@ from pydantic import BaseModel, Field import os from pathlib import Path from enum import Enum -from encoder import inference as encoder +from models.encoder import inference as encoder import librosa from scipy.io.wavfile import write import re import numpy as np -from mkgui.base.components.types import FileContent -from vocoder.hifigan import inference as gan_vocoder -from synthesizer.inference import Synthesizer +from control.mkgui.base.components.types import FileContent +from models.vocoder.hifigan import inference as gan_vocoder +from models.synthesizer.inference import Synthesizer from typing import Any, Tuple import matplotlib.pyplot as plt # Constants -AUDIO_SAMPLES_DIR = f"samples{os.sep}" -SYN_MODELS_DIRT = f"synthesizer{os.sep}saved_models" -ENC_MODELS_DIRT = f"encoder{os.sep}saved_models" -VOC_MODELS_DIRT = f"vocoder{os.sep}saved_models" +AUDIO_SAMPLES_DIR = f"data{os.sep}samples{os.sep}" +SYN_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}synthesizer" +ENC_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}encoder" +VOC_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}vocoder" TEMP_SOURCE_AUDIO = f"wavs{os.sep}temp_source.wav" TEMP_RESULT_AUDIO = f"wavs{os.sep}temp_result.wav" if not os.path.isdir("wavs"): @@ -31,7 +31,7 @@ if os.path.isdir(SYN_MODELS_DIRT): synthesizers = Enum('synthesizers', list((file.name, file) for file in Path(SYN_MODELS_DIRT).glob("**/*.pt"))) print("Loaded synthesizer models: " + str(len(synthesizers))) else: - raise Exception(f"Model folder {SYN_MODELS_DIRT} doesn't exist.") + raise Exception(f"Model folder {SYN_MODELS_DIRT} doesn't exist. 请将模型文件位置移动到上述位置中进行重试!") if os.path.isdir(ENC_MODELS_DIRT): encoders = Enum('encoders', list((file.name, file) for file in Path(ENC_MODELS_DIRT).glob("**/*.pt"))) diff --git a/mkgui/app_vc.py b/control/mkgui/app_vc.py similarity index 89% rename from mkgui/app_vc.py rename to control/mkgui/app_vc.py index e4012e6..58a49c4 100644 --- a/mkgui/app_vc.py +++ b/control/mkgui/app_vc.py @@ -1,27 +1,26 @@ -from synthesizer.inference import Synthesizer -from pydantic import BaseModel, Field -from encoder import inference as speacker_encoder -import torch import os -from pathlib import Path from enum import Enum -import ppg_extractor as Extractor -import ppg2mel as Convertor -import librosa -from scipy.io.wavfile import write -import re -import numpy as np -from mkgui.base.components.types import FileContent -from vocoder.hifigan import inference as gan_vocoder +from pathlib import Path from typing import Any, Tuple -import matplotlib.pyplot as plt +import librosa +import matplotlib.pyplot as plt +import torch +from pydantic import BaseModel, Field +from scipy.io.wavfile import write + +import models.ppg2mel as Convertor +import models.ppg_extractor as Extractor +from control.mkgui.base.components.types import FileContent +from models.encoder import inference as speacker_encoder +from models.synthesizer.inference import Synthesizer +from models.vocoder.hifigan import inference as gan_vocoder # Constants -AUDIO_SAMPLES_DIR = f'samples{os.sep}' -EXT_MODELS_DIRT = f'ppg_extractor{os.sep}saved_models' -CONV_MODELS_DIRT = f'ppg2mel{os.sep}saved_models' -VOC_MODELS_DIRT = f'vocoder{os.sep}saved_models' +AUDIO_SAMPLES_DIR = f'data{os.sep}samples{os.sep}' +EXT_MODELS_DIRT = f'data{os.sep}ckpt{os.sep}ppg_extractor' +CONV_MODELS_DIRT = f'data{os.sep}ckpt{os.sep}ppg2mel' +VOC_MODELS_DIRT = f'data{os.sep}ckpt{os.sep}vocoder' TEMP_SOURCE_AUDIO = f'wavs{os.sep}temp_source.wav' TEMP_TARGET_AUDIO = f'wavs{os.sep}temp_target.wav' TEMP_RESULT_AUDIO = f'wavs{os.sep}temp_result.wav' @@ -132,9 +131,10 @@ def convert(input: Input) -> Output: ppg = extractor.extract_from_wav(src_wav) # Import necessary dependency of Voice Conversion - from utils.f0_utils import compute_f0, f02lf0, compute_mean_std, get_converted_lf0uv + from utils.f0_utils import (compute_f0, compute_mean_std, f02lf0, + get_converted_lf0uv) ref_lf0_mean, ref_lf0_std = compute_mean_std(f02lf0(compute_f0(ref_wav))) - speacker_encoder.load_model(Path(f"encoder{os.sep}saved_models{os.sep}pretrained_bak_5805000.pt")) + speacker_encoder.load_model(Path(f"data{os.sep}ckpt{os.sep}encoder{os.sep}pretrained_bak_5805000.pt")) embed = speacker_encoder.embed_utterance(ref_wav) lf0_uv = get_converted_lf0uv(src_wav, ref_lf0_mean, ref_lf0_std, convert=True) min_len = min(ppg.shape[1], len(lf0_uv)) diff --git a/mkgui/base/__init__.py b/control/mkgui/base/__init__.py similarity index 100% rename from mkgui/base/__init__.py rename to control/mkgui/base/__init__.py diff --git a/mkgui/base/api/__init__.py b/control/mkgui/base/api/__init__.py similarity index 100% rename from mkgui/base/api/__init__.py rename to control/mkgui/base/api/__init__.py diff --git a/mkgui/base/api/fastapi_utils.py b/control/mkgui/base/api/fastapi_utils.py similarity index 100% rename from mkgui/base/api/fastapi_utils.py rename to control/mkgui/base/api/fastapi_utils.py diff --git a/mkgui/base/components/__init__.py b/control/mkgui/base/components/__init__.py similarity index 100% rename from mkgui/base/components/__init__.py rename to control/mkgui/base/components/__init__.py diff --git a/mkgui/base/components/outputs.py b/control/mkgui/base/components/outputs.py similarity index 100% rename from mkgui/base/components/outputs.py rename to control/mkgui/base/components/outputs.py diff --git a/mkgui/base/components/types.py b/control/mkgui/base/components/types.py similarity index 100% rename from mkgui/base/components/types.py rename to control/mkgui/base/components/types.py diff --git a/mkgui/base/core.py b/control/mkgui/base/core.py similarity index 100% rename from mkgui/base/core.py rename to control/mkgui/base/core.py diff --git a/mkgui/base/ui/__init__.py b/control/mkgui/base/ui/__init__.py similarity index 100% rename from mkgui/base/ui/__init__.py rename to control/mkgui/base/ui/__init__.py diff --git a/mkgui/base/ui/schema_utils.py b/control/mkgui/base/ui/schema_utils.py similarity index 100% rename from mkgui/base/ui/schema_utils.py rename to control/mkgui/base/ui/schema_utils.py diff --git a/mkgui/base/ui/streamlit_ui.py b/control/mkgui/base/ui/streamlit_ui.py similarity index 98% rename from mkgui/base/ui/streamlit_ui.py rename to control/mkgui/base/ui/streamlit_ui.py index fb65339..b3a18b4 100644 --- a/mkgui/base/ui/streamlit_ui.py +++ b/control/mkgui/base/ui/streamlit_ui.py @@ -14,14 +14,13 @@ from fastapi.encoders import jsonable_encoder from loguru import logger from pydantic import BaseModel, ValidationError, parse_obj_as -from mkgui.base import Opyrator -from mkgui.base.core import name_to_title -from mkgui.base.ui import schema_utils -from mkgui.base.ui.streamlit_utils import CUSTOM_STREAMLIT_CSS +from control.mkgui.base import Opyrator +from control.mkgui.base.core import name_to_title +from . import schema_utils +from .streamlit_utils import CUSTOM_STREAMLIT_CSS STREAMLIT_RUNNER_SNIPPET = """ -from mkgui.base.ui import render_streamlit_ui -from mkgui.base import Opyrator +from control.mkgui.base.ui import render_streamlit_ui import streamlit as st @@ -807,18 +806,18 @@ class OutputUI: def getOpyrator(mode: str) -> Opyrator: if mode == None or mode.startswith('VC'): - from mkgui.app_vc import convert + from control.mkgui.app_vc import convert return Opyrator(convert) if mode == None or mode.startswith('预处理'): - from mkgui.preprocess import preprocess + from control.mkgui.preprocess import preprocess return Opyrator(preprocess) if mode == None or mode.startswith('模型训练'): - from mkgui.train import train + from control.mkgui.train import train return Opyrator(train) if mode == None or mode.startswith('模型训练(VC)'): - from mkgui.train_vc import train_vc + from control.mkgui.train_vc import train_vc return Opyrator(train_vc) - from mkgui.app import synthesize + from control.mkgui.app import synthesize return Opyrator(synthesize) @@ -845,7 +844,7 @@ def render_streamlit_ui() -> None: col2.title(title) col2.markdown("欢迎使用MockingBird Web 2") - image = Image.open(path.join('mkgui', 'static', 'mb.png')) + image = Image.open(path.join('control','mkgui', 'static', 'mb.png')) col1.image(image) st.markdown("---") diff --git a/mkgui/base/ui/streamlit_utils.py b/control/mkgui/base/ui/streamlit_utils.py similarity index 100% rename from mkgui/base/ui/streamlit_utils.py rename to control/mkgui/base/ui/streamlit_utils.py diff --git a/mkgui/preprocess.py b/control/mkgui/preprocess.py similarity index 94% rename from mkgui/preprocess.py rename to control/mkgui/preprocess.py index 91579b6..886bffd 100644 --- a/mkgui/preprocess.py +++ b/control/mkgui/preprocess.py @@ -6,8 +6,8 @@ from typing import Any, Tuple # Constants -EXT_MODELS_DIRT = f"ppg_extractor{os.sep}saved_models" -ENC_MODELS_DIRT = f"encoder{os.sep}saved_models" +EXT_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}ppg_extractor" +ENC_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}encoder" if os.path.isdir(EXT_MODELS_DIRT): @@ -83,7 +83,7 @@ def preprocess(input: Input) -> Output: """Preprocess(预处理)""" finished = 0 if input.model == Model.VC_PPG2MEL: - from ppg2mel.preprocess import preprocess_dataset + from models.ppg2mel.preprocess import preprocess_dataset finished = preprocess_dataset( datasets_root=Path(input.datasets_root), dataset=input.dataset, diff --git a/mkgui/static/mb.png b/control/mkgui/static/mb.png similarity index 100% rename from mkgui/static/mb.png rename to control/mkgui/static/mb.png diff --git a/mkgui/train.py b/control/mkgui/train.py similarity index 88% rename from mkgui/train.py rename to control/mkgui/train.py index 7104d54..4c76b09 100644 --- a/mkgui/train.py +++ b/control/mkgui/train.py @@ -3,17 +3,17 @@ import os from pathlib import Path from enum import Enum from typing import Any -from synthesizer.hparams import hparams -from synthesizer.train import train as synt_train +from models.synthesizer.hparams import hparams +from models.synthesizer.train import train as synt_train # Constants -SYN_MODELS_DIRT = f"synthesizer{os.sep}saved_models" -ENC_MODELS_DIRT = f"encoder{os.sep}saved_models" +SYN_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}synthesizer" +ENC_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}encoder" -# EXT_MODELS_DIRT = f"ppg_extractor{os.sep}saved_models" -# CONV_MODELS_DIRT = f"ppg2mel{os.sep}saved_models" -# ENC_MODELS_DIRT = f"encoder{os.sep}saved_models" +# EXT_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}ppg_extractor" +# CONV_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}ppg2mel" +# ENC_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}encoder" # Pre-Load models if os.path.isdir(SYN_MODELS_DIRT): @@ -96,7 +96,7 @@ def train(input: Input) -> Output: synt_train( input.run_id, input.input_root, - f"synthesizer{os.sep}saved_models", + f"data{os.sep}ckpt{os.sep}synthesizer", input.save_every, input.backup_every, input.log_every, diff --git a/mkgui/train_vc.py b/control/mkgui/train_vc.py similarity index 95% rename from mkgui/train_vc.py rename to control/mkgui/train_vc.py index 8c23372..16a1582 100644 --- a/mkgui/train_vc.py +++ b/control/mkgui/train_vc.py @@ -9,9 +9,9 @@ from utils.util import AttrDict import torch # Constants -EXT_MODELS_DIRT = f"ppg_extractor{os.sep}saved_models" -CONV_MODELS_DIRT = f"ppg2mel{os.sep}saved_models" -ENC_MODELS_DIRT = f"encoder{os.sep}saved_models" +EXT_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}ppg_extractor" +CONV_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}ppg2mel" +ENC_MODELS_DIRT = f"data{os.sep}ckpt{os.sep}encoder" if os.path.isdir(EXT_MODELS_DIRT): @@ -144,7 +144,7 @@ def train_vc(input: Input) -> Output: if torch.cuda.is_available(): torch.cuda.manual_seed_all(input.seed) mode = "train" - from ppg2mel.train.train_linglf02mel_seq2seq_oneshotvc import Solver + from models.ppg2mel.train.train_linglf02mel_seq2seq_oneshotvc import Solver solver = Solver(config, params, mode) solver.load_data() solver.set_model() diff --git a/toolbox/__init__.py b/control/toolbox/__init__.py similarity index 97% rename from toolbox/__init__.py rename to control/toolbox/__init__.py index 7aa4e11..9bd8f23 100644 --- a/toolbox/__init__.py +++ b/control/toolbox/__init__.py @@ -1,12 +1,12 @@ -from toolbox.ui import UI -from encoder import inference as encoder -from synthesizer.inference import Synthesizer -from vocoder.wavernn import inference as rnn_vocoder -from vocoder.hifigan import inference as gan_vocoder -from vocoder.fregan import inference as fgan_vocoder +from control.toolbox.ui import UI +from models.encoder import inference as encoder +from models.synthesizer.inference import Synthesizer +from models.vocoder.wavernn import inference as rnn_vocoder +from models.vocoder.hifigan import inference as gan_vocoder +from models.vocoder.fregan import inference as fgan_vocoder from pathlib import Path from time import perf_counter as timer -from toolbox.utterance import Utterance +from control.toolbox.utterance import Utterance import numpy as np import traceback import sys @@ -396,7 +396,7 @@ class Toolbox: self.ui.log("Loading the extractor %s... " % model_fpath) self.ui.set_loading(1) start = timer() - import ppg_extractor as extractor + import models.ppg_extractor as extractor self.extractor = extractor.load_model(model_fpath) self.ui.log("Done (%dms)." % int(1000 * (timer() - start)), "append") self.ui.set_loading(0) @@ -408,7 +408,7 @@ class Toolbox: self.ui.log("Loading the convertor %s... " % model_fpath) self.ui.set_loading(1) start = timer() - import ppg2mel as convertor + import models.ppg2mel as convertor self.convertor = convertor.load_model( model_fpath) self.ui.log("Done (%dms)." % int(1000 * (timer() - start)), "append") self.ui.set_loading(0) diff --git a/toolbox/assets/mb.png b/control/toolbox/assets/mb.png similarity index 100% rename from toolbox/assets/mb.png rename to control/toolbox/assets/mb.png diff --git a/toolbox/ui.py b/control/toolbox/ui.py similarity index 99% rename from toolbox/ui.py rename to control/toolbox/ui.py index d50f30c..c7b6223 100644 --- a/toolbox/ui.py +++ b/control/toolbox/ui.py @@ -4,8 +4,8 @@ from PyQt5.QtWidgets import * import matplotlib.pyplot as plt from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.figure import Figure -from encoder.inference import plot_embedding_as_heatmap -from toolbox.utterance import Utterance +from models.encoder.inference import plot_embedding_as_heatmap +from control.toolbox.utterance import Utterance from pathlib import Path from typing import List, Set import sounddevice as sd diff --git a/toolbox/utterance.py b/control/toolbox/utterance.py similarity index 100% rename from toolbox/utterance.py rename to control/toolbox/utterance.py diff --git a/samples/T0055G0013S0005.wav b/data/samples/T0055G0013S0005.wav similarity index 100% rename from samples/T0055G0013S0005.wav rename to data/samples/T0055G0013S0005.wav diff --git a/demo_toolbox.py b/demo_toolbox.py index 7030bd5..3304e23 100644 --- a/demo_toolbox.py +++ b/demo_toolbox.py @@ -1,5 +1,5 @@ from pathlib import Path -from toolbox import Toolbox +from control.toolbox import Toolbox from utils.argutils import print_args from utils.modelutils import check_model_paths import argparse diff --git a/encoder/data_objects/__init__.py b/encoder/data_objects/__init__.py deleted file mode 100644 index ef04ade..0000000 --- a/encoder/data_objects/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from encoder.data_objects.speaker_verification_dataset import SpeakerVerificationDataset -from encoder.data_objects.speaker_verification_dataset import SpeakerVerificationDataLoader diff --git a/encoder/saved_models/pretrained.pt b/encoder/saved_models/pretrained.pt deleted file mode 100644 index e817ffe..0000000 Binary files a/encoder/saved_models/pretrained.pt and /dev/null differ diff --git a/gen_voice.py b/gen_voice.py index 3be4159..cd0c9f8 100644 --- a/gen_voice.py +++ b/gen_voice.py @@ -1,23 +1,15 @@ -from encoder.params_model import model_embedding_size as speaker_embedding_size -from utils.argutils import print_args -from utils.modelutils import check_model_paths -from synthesizer.inference import Synthesizer -from encoder import inference as encoder -from vocoder.wavernn import inference as rnn_vocoder -from vocoder.hifigan import inference as gan_vocoder +from models.synthesizer.inference import Synthesizer +from models.encoder import inference as encoder +from models.vocoder.hifigan import inference as gan_vocoder from pathlib import Path import numpy as np import soundfile as sf -import librosa -import argparse import torch import sys import os import re import cn2an -import glob -from audioread.exceptions import NoBackendError vocoder = gan_vocoder def gen_one_wav(synthesizer, in_fpath, embed, texts, file_name, seq): diff --git a/ppg_extractor/encoder/__init__.py b/models/encoder/__init__.py similarity index 100% rename from ppg_extractor/encoder/__init__.py rename to models/encoder/__init__.py diff --git a/encoder/audio.py b/models/encoder/audio.py similarity index 99% rename from encoder/audio.py rename to models/encoder/audio.py index 5c087ee..7d2fe2d 100644 --- a/encoder/audio.py +++ b/models/encoder/audio.py @@ -1,5 +1,5 @@ from scipy.ndimage.morphology import binary_dilation -from encoder.params_data import * +from models.encoder.params_data import * from pathlib import Path from typing import Optional, Union from warnings import warn diff --git a/encoder/config.py b/models/encoder/config.py similarity index 100% rename from encoder/config.py rename to models/encoder/config.py diff --git a/models/encoder/data_objects/__init__.py b/models/encoder/data_objects/__init__.py new file mode 100644 index 0000000..6ecc942 --- /dev/null +++ b/models/encoder/data_objects/__init__.py @@ -0,0 +1,2 @@ +from models.encoder.data_objects.speaker_verification_dataset import SpeakerVerificationDataset +from models.encoder.data_objects.speaker_verification_dataset import SpeakerVerificationDataLoader diff --git a/encoder/data_objects/random_cycler.py b/models/encoder/data_objects/random_cycler.py similarity index 100% rename from encoder/data_objects/random_cycler.py rename to models/encoder/data_objects/random_cycler.py diff --git a/encoder/data_objects/speaker.py b/models/encoder/data_objects/speaker.py similarity index 93% rename from encoder/data_objects/speaker.py rename to models/encoder/data_objects/speaker.py index 494e882..731b16a 100644 --- a/encoder/data_objects/speaker.py +++ b/models/encoder/data_objects/speaker.py @@ -1,5 +1,5 @@ -from encoder.data_objects.random_cycler import RandomCycler -from encoder.data_objects.utterance import Utterance +from models.encoder.data_objects.random_cycler import RandomCycler +from models.encoder.data_objects.utterance import Utterance from pathlib import Path # Contains the set of utterances of a single speaker diff --git a/encoder/data_objects/speaker_batch.py b/models/encoder/data_objects/speaker_batch.py similarity index 91% rename from encoder/data_objects/speaker_batch.py rename to models/encoder/data_objects/speaker_batch.py index 56651db..13d6963 100644 --- a/encoder/data_objects/speaker_batch.py +++ b/models/encoder/data_objects/speaker_batch.py @@ -1,6 +1,6 @@ import numpy as np from typing import List -from encoder.data_objects.speaker import Speaker +from models.encoder.data_objects.speaker import Speaker class SpeakerBatch: def __init__(self, speakers: List[Speaker], utterances_per_speaker: int, n_frames: int): diff --git a/encoder/data_objects/speaker_verification_dataset.py b/models/encoder/data_objects/speaker_verification_dataset.py similarity index 88% rename from encoder/data_objects/speaker_verification_dataset.py rename to models/encoder/data_objects/speaker_verification_dataset.py index 77a6e05..f3197e1 100644 --- a/encoder/data_objects/speaker_verification_dataset.py +++ b/models/encoder/data_objects/speaker_verification_dataset.py @@ -1,7 +1,7 @@ -from encoder.data_objects.random_cycler import RandomCycler -from encoder.data_objects.speaker_batch import SpeakerBatch -from encoder.data_objects.speaker import Speaker -from encoder.params_data import partials_n_frames +from models.encoder.data_objects.random_cycler import RandomCycler +from models.encoder.data_objects.speaker_batch import SpeakerBatch +from models.encoder.data_objects.speaker import Speaker +from models.encoder.params_data import partials_n_frames from torch.utils.data import Dataset, DataLoader from pathlib import Path diff --git a/encoder/data_objects/utterance.py b/models/encoder/data_objects/utterance.py similarity index 100% rename from encoder/data_objects/utterance.py rename to models/encoder/data_objects/utterance.py diff --git a/encoder/inference.py b/models/encoder/inference.py similarity index 97% rename from encoder/inference.py rename to models/encoder/inference.py index af9a529..3ced714 100644 --- a/encoder/inference.py +++ b/models/encoder/inference.py @@ -1,8 +1,8 @@ -from encoder.params_data import * -from encoder.model import SpeakerEncoder -from encoder.audio import preprocess_wav # We want to expose this function from here +from models.encoder.params_data import * +from models.encoder.model import SpeakerEncoder +from models.encoder.audio import preprocess_wav # We want to expose this function from here from matplotlib import cm -from encoder import audio +from models.encoder import audio from pathlib import Path import matplotlib.pyplot as plt import numpy as np diff --git a/encoder/model.py b/models/encoder/model.py similarity index 98% rename from encoder/model.py rename to models/encoder/model.py index e050d32..2fc0bbd 100644 --- a/encoder/model.py +++ b/models/encoder/model.py @@ -1,5 +1,5 @@ -from encoder.params_model import * -from encoder.params_data import * +from models.encoder.params_model import * +from models.encoder.params_data import * from scipy.interpolate import interp1d from sklearn.metrics import roc_curve from torch.nn.utils import clip_grad_norm_ diff --git a/encoder/params_data.py b/models/encoder/params_data.py similarity index 100% rename from encoder/params_data.py rename to models/encoder/params_data.py diff --git a/encoder/params_model.py b/models/encoder/params_model.py similarity index 100% rename from encoder/params_model.py rename to models/encoder/params_model.py diff --git a/encoder/preprocess.py b/models/encoder/preprocess.py similarity index 97% rename from encoder/preprocess.py rename to models/encoder/preprocess.py index 69986bb..d9e5d53 100644 --- a/encoder/preprocess.py +++ b/models/encoder/preprocess.py @@ -1,8 +1,8 @@ from multiprocess.pool import ThreadPool -from encoder.params_data import * -from encoder.config import librispeech_datasets, anglophone_nationalites +from models.encoder.params_data import * +from models.encoder.config import librispeech_datasets, anglophone_nationalites from datetime import datetime -from encoder import audio +from models.encoder import audio from pathlib import Path from tqdm import tqdm import numpy as np @@ -22,7 +22,7 @@ class DatasetLog: self._log_params() def _log_params(self): - from encoder import params_data + from models.encoder import params_data self.write_line("Parameter values:") for param_name in (p for p in dir(params_data) if not p.startswith("__")): value = getattr(params_data, param_name) diff --git a/encoder/train.py b/models/encoder/train.py similarity index 95% rename from encoder/train.py rename to models/encoder/train.py index 619952e..7b9c72e 100644 --- a/encoder/train.py +++ b/models/encoder/train.py @@ -1,7 +1,7 @@ -from encoder.visualizations import Visualizations -from encoder.data_objects import SpeakerVerificationDataLoader, SpeakerVerificationDataset -from encoder.params_model import * -from encoder.model import SpeakerEncoder +from models.encoder.visualizations import Visualizations +from models.encoder.data_objects import SpeakerVerificationDataLoader, SpeakerVerificationDataset +from models.encoder.params_model import * +from models.encoder.model import SpeakerEncoder from utils.profiler import Profiler from pathlib import Path import torch diff --git a/encoder/visualizations.py b/models/encoder/visualizations.py similarity index 97% rename from encoder/visualizations.py rename to models/encoder/visualizations.py index 980c74f..f0b0b7c 100644 --- a/encoder/visualizations.py +++ b/models/encoder/visualizations.py @@ -1,4 +1,4 @@ -from encoder.data_objects.speaker_verification_dataset import SpeakerVerificationDataset +from models.encoder.data_objects.speaker_verification_dataset import SpeakerVerificationDataset from datetime import datetime from time import perf_counter as timer import matplotlib.pyplot as plt @@ -65,8 +65,8 @@ class Visualizations: def log_params(self): if self.disabled: return - from encoder import params_data - from encoder import params_model + from models.encoder import params_data + from models.encoder import params_model param_string = "Model parameters:
" for param_name in (p for p in dir(params_model) if not p.startswith("__")): value = getattr(params_model, param_name) diff --git a/ppg2mel/__init__.py b/models/ppg2mel/__init__.py similarity index 100% rename from ppg2mel/__init__.py rename to models/ppg2mel/__init__.py diff --git a/ppg2mel/preprocess.py b/models/ppg2mel/preprocess.py similarity index 97% rename from ppg2mel/preprocess.py rename to models/ppg2mel/preprocess.py index 0feee6e..f575abb 100644 --- a/ppg2mel/preprocess.py +++ b/models/ppg2mel/preprocess.py @@ -7,10 +7,10 @@ from pathlib import Path import soundfile import resampy -from ppg_extractor import load_model +from models.ppg_extractor import load_model import encoder.inference as Encoder -from encoder.audio import preprocess_wav -from encoder import audio +from models.encoder.audio import preprocess_wav +from models.encoder import audio from utils.f0_utils import compute_f0 from torch.multiprocessing import Pool, cpu_count diff --git a/ppg2mel/rnn_decoder_mol.py b/models/ppg2mel/rnn_decoder_mol.py similarity index 100% rename from ppg2mel/rnn_decoder_mol.py rename to models/ppg2mel/rnn_decoder_mol.py diff --git a/ppg2mel/train.py b/models/ppg2mel/train.py similarity index 97% rename from ppg2mel/train.py rename to models/ppg2mel/train.py index d3ef729..80aef06 100644 --- a/ppg2mel/train.py +++ b/models/ppg2mel/train.py @@ -3,7 +3,7 @@ import torch import argparse import numpy as np from utils.load_yaml import HpsYaml -from ppg2mel.train.train_linglf02mel_seq2seq_oneshotvc import Solver +from models.ppg2mel.train.train_linglf02mel_seq2seq_oneshotvc import Solver # For reproducibility, comment these may speed up training torch.backends.cudnn.deterministic = True diff --git a/ppg2mel/train/__init__.py b/models/ppg2mel/train/__init__.py similarity index 100% rename from ppg2mel/train/__init__.py rename to models/ppg2mel/train/__init__.py diff --git a/ppg2mel/train/loss.py b/models/ppg2mel/train/loss.py similarity index 100% rename from ppg2mel/train/loss.py rename to models/ppg2mel/train/loss.py diff --git a/ppg2mel/train/optim.py b/models/ppg2mel/train/optim.py similarity index 100% rename from ppg2mel/train/optim.py rename to models/ppg2mel/train/optim.py diff --git a/ppg2mel/train/option.py b/models/ppg2mel/train/option.py similarity index 100% rename from ppg2mel/train/option.py rename to models/ppg2mel/train/option.py diff --git a/ppg2mel/train/solver.py b/models/ppg2mel/train/solver.py similarity index 100% rename from ppg2mel/train/solver.py rename to models/ppg2mel/train/solver.py diff --git a/ppg2mel/train/train_linglf02mel_seq2seq_oneshotvc.py b/models/ppg2mel/train/train_linglf02mel_seq2seq_oneshotvc.py similarity index 99% rename from ppg2mel/train/train_linglf02mel_seq2seq_oneshotvc.py rename to models/ppg2mel/train/train_linglf02mel_seq2seq_oneshotvc.py index daf1c6a..53d0dac 100644 --- a/ppg2mel/train/train_linglf02mel_seq2seq_oneshotvc.py +++ b/models/ppg2mel/train/train_linglf02mel_seq2seq_oneshotvc.py @@ -14,7 +14,7 @@ from utils.data_load import OneshotVcDataset, MultiSpkVcCollate from .loss import MaskedMSELoss from .optim import Optimizer from utils.util import human_format -from ppg2mel import MelDecoderMOLv2 +from models.ppg2mel import MelDecoderMOLv2 class Solver(BaseSolver): diff --git a/ppg2mel/utils/abs_model.py b/models/ppg2mel/utils/abs_model.py similarity index 100% rename from ppg2mel/utils/abs_model.py rename to models/ppg2mel/utils/abs_model.py diff --git a/ppg2mel/utils/basic_layers.py b/models/ppg2mel/utils/basic_layers.py similarity index 100% rename from ppg2mel/utils/basic_layers.py rename to models/ppg2mel/utils/basic_layers.py diff --git a/ppg2mel/utils/cnn_postnet.py b/models/ppg2mel/utils/cnn_postnet.py similarity index 100% rename from ppg2mel/utils/cnn_postnet.py rename to models/ppg2mel/utils/cnn_postnet.py diff --git a/ppg2mel/utils/mol_attention.py b/models/ppg2mel/utils/mol_attention.py similarity index 100% rename from ppg2mel/utils/mol_attention.py rename to models/ppg2mel/utils/mol_attention.py diff --git a/ppg2mel/utils/nets_utils.py b/models/ppg2mel/utils/nets_utils.py similarity index 100% rename from ppg2mel/utils/nets_utils.py rename to models/ppg2mel/utils/nets_utils.py diff --git a/ppg2mel/utils/vc_utils.py b/models/ppg2mel/utils/vc_utils.py similarity index 100% rename from ppg2mel/utils/vc_utils.py rename to models/ppg2mel/utils/vc_utils.py diff --git a/ppg_extractor/__init__.py b/models/ppg_extractor/__init__.py similarity index 100% rename from ppg_extractor/__init__.py rename to models/ppg_extractor/__init__.py diff --git a/ppg_extractor/e2e_asr_common.py b/models/ppg_extractor/e2e_asr_common.py similarity index 100% rename from ppg_extractor/e2e_asr_common.py rename to models/ppg_extractor/e2e_asr_common.py diff --git a/web/config/__init__.py b/models/ppg_extractor/encoder/__init__.py similarity index 100% rename from web/config/__init__.py rename to models/ppg_extractor/encoder/__init__.py diff --git a/ppg_extractor/encoder/attention.py b/models/ppg_extractor/encoder/attention.py similarity index 100% rename from ppg_extractor/encoder/attention.py rename to models/ppg_extractor/encoder/attention.py diff --git a/ppg_extractor/encoder/conformer_encoder.py b/models/ppg_extractor/encoder/conformer_encoder.py similarity index 100% rename from ppg_extractor/encoder/conformer_encoder.py rename to models/ppg_extractor/encoder/conformer_encoder.py diff --git a/ppg_extractor/encoder/convolution.py b/models/ppg_extractor/encoder/convolution.py similarity index 100% rename from ppg_extractor/encoder/convolution.py rename to models/ppg_extractor/encoder/convolution.py diff --git a/ppg_extractor/encoder/embedding.py b/models/ppg_extractor/encoder/embedding.py similarity index 100% rename from ppg_extractor/encoder/embedding.py rename to models/ppg_extractor/encoder/embedding.py diff --git a/ppg_extractor/encoder/encoder.py b/models/ppg_extractor/encoder/encoder.py similarity index 100% rename from ppg_extractor/encoder/encoder.py rename to models/ppg_extractor/encoder/encoder.py diff --git a/ppg_extractor/encoder/encoder_layer.py b/models/ppg_extractor/encoder/encoder_layer.py similarity index 100% rename from ppg_extractor/encoder/encoder_layer.py rename to models/ppg_extractor/encoder/encoder_layer.py diff --git a/ppg_extractor/encoder/layer_norm.py b/models/ppg_extractor/encoder/layer_norm.py similarity index 100% rename from ppg_extractor/encoder/layer_norm.py rename to models/ppg_extractor/encoder/layer_norm.py diff --git a/ppg_extractor/encoder/multi_layer_conv.py b/models/ppg_extractor/encoder/multi_layer_conv.py similarity index 100% rename from ppg_extractor/encoder/multi_layer_conv.py rename to models/ppg_extractor/encoder/multi_layer_conv.py diff --git a/ppg_extractor/encoder/positionwise_feed_forward.py b/models/ppg_extractor/encoder/positionwise_feed_forward.py similarity index 100% rename from ppg_extractor/encoder/positionwise_feed_forward.py rename to models/ppg_extractor/encoder/positionwise_feed_forward.py diff --git a/ppg_extractor/encoder/repeat.py b/models/ppg_extractor/encoder/repeat.py similarity index 100% rename from ppg_extractor/encoder/repeat.py rename to models/ppg_extractor/encoder/repeat.py diff --git a/ppg_extractor/encoder/subsampling.py b/models/ppg_extractor/encoder/subsampling.py similarity index 100% rename from ppg_extractor/encoder/subsampling.py rename to models/ppg_extractor/encoder/subsampling.py diff --git a/ppg_extractor/encoder/swish.py b/models/ppg_extractor/encoder/swish.py similarity index 100% rename from ppg_extractor/encoder/swish.py rename to models/ppg_extractor/encoder/swish.py diff --git a/ppg_extractor/encoder/vgg.py b/models/ppg_extractor/encoder/vgg.py similarity index 100% rename from ppg_extractor/encoder/vgg.py rename to models/ppg_extractor/encoder/vgg.py diff --git a/ppg_extractor/encoders.py b/models/ppg_extractor/encoders.py similarity index 100% rename from ppg_extractor/encoders.py rename to models/ppg_extractor/encoders.py diff --git a/ppg_extractor/frontend.py b/models/ppg_extractor/frontend.py similarity index 100% rename from ppg_extractor/frontend.py rename to models/ppg_extractor/frontend.py diff --git a/ppg_extractor/log_mel.py b/models/ppg_extractor/log_mel.py similarity index 100% rename from ppg_extractor/log_mel.py rename to models/ppg_extractor/log_mel.py diff --git a/ppg_extractor/nets_utils.py b/models/ppg_extractor/nets_utils.py similarity index 100% rename from ppg_extractor/nets_utils.py rename to models/ppg_extractor/nets_utils.py diff --git a/ppg_extractor/stft.py b/models/ppg_extractor/stft.py similarity index 100% rename from ppg_extractor/stft.py rename to models/ppg_extractor/stft.py diff --git a/ppg_extractor/utterance_mvn.py b/models/ppg_extractor/utterance_mvn.py similarity index 100% rename from ppg_extractor/utterance_mvn.py rename to models/ppg_extractor/utterance_mvn.py diff --git a/synthesizer/LICENSE.txt b/models/synthesizer/LICENSE.txt similarity index 100% rename from synthesizer/LICENSE.txt rename to models/synthesizer/LICENSE.txt diff --git a/models/synthesizer/__init__.py b/models/synthesizer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/synthesizer/audio.py b/models/synthesizer/audio.py similarity index 100% rename from synthesizer/audio.py rename to models/synthesizer/audio.py diff --git a/synthesizer/gst_hyperparameters.py b/models/synthesizer/gst_hyperparameters.py similarity index 100% rename from synthesizer/gst_hyperparameters.py rename to models/synthesizer/gst_hyperparameters.py diff --git a/synthesizer/hparams.py b/models/synthesizer/hparams.py similarity index 100% rename from synthesizer/hparams.py rename to models/synthesizer/hparams.py diff --git a/synthesizer/inference.py b/models/synthesizer/inference.py similarity index 96% rename from synthesizer/inference.py rename to models/synthesizer/inference.py index 3ff856b..888f31c 100644 --- a/synthesizer/inference.py +++ b/models/synthesizer/inference.py @@ -1,10 +1,10 @@ import torch -from synthesizer import audio -from synthesizer.hparams import hparams -from synthesizer.models.tacotron import Tacotron -from synthesizer.utils.symbols import symbols -from synthesizer.utils.text import text_to_sequence -from vocoder.display import simple_table +from models.synthesizer import audio +from models.synthesizer.hparams import hparams +from models.synthesizer.models.tacotron import Tacotron +from models.synthesizer.utils.symbols import symbols +from models.synthesizer.utils.text import text_to_sequence +from models.vocoder.display import simple_table from pathlib import Path from typing import Union, List import numpy as np diff --git a/synthesizer/models/base.py b/models/synthesizer/models/base.py similarity index 100% rename from synthesizer/models/base.py rename to models/synthesizer/models/base.py diff --git a/synthesizer/__init__.py b/models/synthesizer/models/sublayer/__init__.py similarity index 100% rename from synthesizer/__init__.py rename to models/synthesizer/models/sublayer/__init__.py diff --git a/synthesizer/models/sublayer/cbhg.py b/models/synthesizer/models/sublayer/cbhg.py similarity index 100% rename from synthesizer/models/sublayer/cbhg.py rename to models/synthesizer/models/sublayer/cbhg.py diff --git a/synthesizer/models/sublayer/common/batch_norm_conv.py b/models/synthesizer/models/sublayer/common/batch_norm_conv.py similarity index 100% rename from synthesizer/models/sublayer/common/batch_norm_conv.py rename to models/synthesizer/models/sublayer/common/batch_norm_conv.py diff --git a/synthesizer/models/sublayer/common/highway_network.py b/models/synthesizer/models/sublayer/common/highway_network.py similarity index 100% rename from synthesizer/models/sublayer/common/highway_network.py rename to models/synthesizer/models/sublayer/common/highway_network.py diff --git a/synthesizer/models/sublayer/global_style_token.py b/models/synthesizer/models/sublayer/global_style_token.py similarity index 97% rename from synthesizer/models/sublayer/global_style_token.py rename to models/synthesizer/models/sublayer/global_style_token.py index 21ce07e..c65924f 100644 --- a/synthesizer/models/sublayer/global_style_token.py +++ b/models/synthesizer/models/sublayer/global_style_token.py @@ -2,8 +2,8 @@ import torch import torch.nn as nn import torch.nn.init as init import torch.nn.functional as tFunctional -from synthesizer.gst_hyperparameters import GSTHyperparameters as hp -from synthesizer.hparams import hparams +from models.synthesizer.gst_hyperparameters import GSTHyperparameters as hp +from models.synthesizer.hparams import hparams class GlobalStyleToken(nn.Module): diff --git a/synthesizer/models/sublayer/lsa.py b/models/synthesizer/models/sublayer/lsa.py similarity index 100% rename from synthesizer/models/sublayer/lsa.py rename to models/synthesizer/models/sublayer/lsa.py diff --git a/synthesizer/models/sublayer/pre_net.py b/models/synthesizer/models/sublayer/pre_net.py similarity index 100% rename from synthesizer/models/sublayer/pre_net.py rename to models/synthesizer/models/sublayer/pre_net.py diff --git a/synthesizer/models/tacotron.py b/models/synthesizer/models/tacotron.py similarity index 99% rename from synthesizer/models/tacotron.py rename to models/synthesizer/models/tacotron.py index f8b01bb..cee5b69 100644 --- a/synthesizer/models/tacotron.py +++ b/models/synthesizer/models/tacotron.py @@ -5,8 +5,8 @@ from .sublayer.pre_net import PreNet from .sublayer.cbhg import CBHG from .sublayer.lsa import LSA from .base import Base -from synthesizer.gst_hyperparameters import GSTHyperparameters as gst_hp -from synthesizer.hparams import hparams +from models.synthesizer.gst_hyperparameters import GSTHyperparameters as gst_hp +from models.synthesizer.hparams import hparams class Encoder(nn.Module): def __init__(self, num_chars, embed_dims=512, encoder_dims=256, K=5, num_highways=4, dropout=0.5): diff --git a/synthesizer/preprocess.py b/models/synthesizer/preprocess.py similarity index 95% rename from synthesizer/preprocess.py rename to models/synthesizer/preprocess.py index dc305e4..5299781 100644 --- a/synthesizer/preprocess.py +++ b/models/synthesizer/preprocess.py @@ -5,9 +5,9 @@ from itertools import chain from pathlib import Path from tqdm import tqdm import numpy as np -from encoder import inference as encoder -from synthesizer.preprocess_speaker import preprocess_speaker_general -from synthesizer.preprocess_transcript import preprocess_transcript_aishell3, preprocess_transcript_magicdata +from models.encoder import inference as encoder +from models.synthesizer.preprocess_speaker import preprocess_speaker_general +from models.synthesizer.preprocess_transcript import preprocess_transcript_aishell3, preprocess_transcript_magicdata data_info = { "aidatatang_200zh": { diff --git a/synthesizer/preprocess_speaker.py b/models/synthesizer/preprocess_speaker.py similarity index 98% rename from synthesizer/preprocess_speaker.py rename to models/synthesizer/preprocess_speaker.py index 28ddad4..fcd829f 100644 --- a/synthesizer/preprocess_speaker.py +++ b/models/synthesizer/preprocess_speaker.py @@ -1,9 +1,9 @@ import librosa import numpy as np -from encoder import inference as encoder +from models.encoder import inference as encoder from utils import logmmse -from synthesizer import audio +from models.synthesizer import audio from pathlib import Path from pypinyin import Style from pypinyin.contrib.neutral_tone import NeutralToneWith5Mixin diff --git a/synthesizer/preprocess_transcript.py b/models/synthesizer/preprocess_transcript.py similarity index 100% rename from synthesizer/preprocess_transcript.py rename to models/synthesizer/preprocess_transcript.py diff --git a/synthesizer/synthesize.py b/models/synthesizer/synthesize.py similarity index 94% rename from synthesizer/synthesize.py rename to models/synthesizer/synthesize.py index 49a06b0..8c70b0f 100644 --- a/synthesizer/synthesize.py +++ b/models/synthesizer/synthesize.py @@ -1,9 +1,9 @@ import torch from torch.utils.data import DataLoader -from synthesizer.synthesizer_dataset import SynthesizerDataset, collate_synthesizer -from synthesizer.models.tacotron import Tacotron -from synthesizer.utils.text import text_to_sequence -from synthesizer.utils.symbols import symbols +from models.synthesizer.synthesizer_dataset import SynthesizerDataset, collate_synthesizer +from models.synthesizer.models.tacotron import Tacotron +from models.synthesizer.utils.text import text_to_sequence +from models.synthesizer.utils.symbols import symbols import numpy as np from pathlib import Path from tqdm import tqdm diff --git a/synthesizer/synthesizer_dataset.py b/models/synthesizer/synthesizer_dataset.py similarity index 98% rename from synthesizer/synthesizer_dataset.py rename to models/synthesizer/synthesizer_dataset.py index 9e5ed58..d2b40d8 100644 --- a/synthesizer/synthesizer_dataset.py +++ b/models/synthesizer/synthesizer_dataset.py @@ -2,7 +2,7 @@ import torch from torch.utils.data import Dataset import numpy as np from pathlib import Path -from synthesizer.utils.text import text_to_sequence +from models.synthesizer.utils.text import text_to_sequence class SynthesizerDataset(Dataset): diff --git a/synthesizer/train.py b/models/synthesizer/train.py similarity index 96% rename from synthesizer/train.py rename to models/synthesizer/train.py index bd1f8a0..21e3961 100644 --- a/synthesizer/train.py +++ b/models/synthesizer/train.py @@ -3,14 +3,14 @@ import torch.nn.functional as F from torch import optim from torch.utils.data import DataLoader from torch.utils.tensorboard import SummaryWriter -from synthesizer import audio -from synthesizer.models.tacotron import Tacotron -from synthesizer.synthesizer_dataset import SynthesizerDataset, collate_synthesizer -from synthesizer.utils import ValueWindow, data_parallel_workaround -from synthesizer.utils.plot import plot_spectrogram, plot_spectrogram_and_trace -from synthesizer.utils.symbols import symbols -from synthesizer.utils.text import sequence_to_text -from vocoder.display import * +from models.synthesizer import audio +from models.synthesizer.models.tacotron import Tacotron +from models.synthesizer.synthesizer_dataset import SynthesizerDataset, collate_synthesizer +from models.synthesizer.utils import ValueWindow, data_parallel_workaround +from models.synthesizer.utils.plot import plot_spectrogram, plot_spectrogram_and_trace +from models.synthesizer.utils.symbols import symbols +from models.synthesizer.utils.text import sequence_to_text +from models.vocoder.display import * from datetime import datetime import json import numpy as np diff --git a/synthesizer/utils/__init__.py b/models/synthesizer/utils/__init__.py similarity index 100% rename from synthesizer/utils/__init__.py rename to models/synthesizer/utils/__init__.py diff --git a/synthesizer/utils/_cmudict.py b/models/synthesizer/utils/_cmudict.py similarity index 100% rename from synthesizer/utils/_cmudict.py rename to models/synthesizer/utils/_cmudict.py diff --git a/synthesizer/utils/cleaners.py b/models/synthesizer/utils/cleaners.py similarity index 100% rename from synthesizer/utils/cleaners.py rename to models/synthesizer/utils/cleaners.py diff --git a/synthesizer/utils/numbers.py b/models/synthesizer/utils/numbers.py similarity index 100% rename from synthesizer/utils/numbers.py rename to models/synthesizer/utils/numbers.py diff --git a/synthesizer/utils/plot.py b/models/synthesizer/utils/plot.py similarity index 100% rename from synthesizer/utils/plot.py rename to models/synthesizer/utils/plot.py diff --git a/synthesizer/utils/symbols.py b/models/synthesizer/utils/symbols.py similarity index 100% rename from synthesizer/utils/symbols.py rename to models/synthesizer/utils/symbols.py diff --git a/synthesizer/utils/text.py b/models/synthesizer/utils/text.py similarity index 100% rename from synthesizer/utils/text.py rename to models/synthesizer/utils/text.py diff --git a/vocoder/LICENSE.txt b/models/vocoder/LICENSE.txt similarity index 100% rename from vocoder/LICENSE.txt rename to models/vocoder/LICENSE.txt diff --git a/synthesizer/models/sublayer/__init__.py b/models/vocoder/__init__.py similarity index 100% rename from synthesizer/models/sublayer/__init__.py rename to models/vocoder/__init__.py diff --git a/vocoder/display.py b/models/vocoder/display.py similarity index 100% rename from vocoder/display.py rename to models/vocoder/display.py diff --git a/vocoder/distribution.py b/models/vocoder/distribution.py similarity index 100% rename from vocoder/distribution.py rename to models/vocoder/distribution.py diff --git a/vocoder/fregan/.gitignore b/models/vocoder/fregan/.gitignore similarity index 100% rename from vocoder/fregan/.gitignore rename to models/vocoder/fregan/.gitignore diff --git a/vocoder/fregan/LICENSE b/models/vocoder/fregan/LICENSE similarity index 100% rename from vocoder/fregan/LICENSE rename to models/vocoder/fregan/LICENSE diff --git a/models/vocoder/fregan/__init__.py b/models/vocoder/fregan/__init__.py new file mode 100644 index 0000000..4287ca8 --- /dev/null +++ b/models/vocoder/fregan/__init__.py @@ -0,0 +1 @@ +# \ No newline at end of file diff --git a/vocoder/fregan/config.json b/models/vocoder/fregan/config.json similarity index 100% rename from vocoder/fregan/config.json rename to models/vocoder/fregan/config.json diff --git a/vocoder/fregan/discriminator.py b/models/vocoder/fregan/discriminator.py similarity index 98% rename from vocoder/fregan/discriminator.py rename to models/vocoder/fregan/discriminator.py index 5f94092..be8d4f0 100644 --- a/vocoder/fregan/discriminator.py +++ b/models/vocoder/fregan/discriminator.py @@ -3,9 +3,9 @@ import torch.nn.functional as F import torch.nn as nn from torch.nn import Conv1d, AvgPool1d, Conv2d from torch.nn.utils import weight_norm, spectral_norm -from vocoder.fregan.utils import get_padding -from vocoder.fregan.stft_loss import stft -from vocoder.fregan.dwt import DWT_1D +from models.vocoder.fregan.utils import get_padding +from models.vocoder.fregan.stft_loss import stft +from models.vocoder.fregan.dwt import DWT_1D LRELU_SLOPE = 0.1 diff --git a/vocoder/fregan/dwt.py b/models/vocoder/fregan/dwt.py similarity index 100% rename from vocoder/fregan/dwt.py rename to models/vocoder/fregan/dwt.py diff --git a/vocoder/fregan/generator.py b/models/vocoder/fregan/generator.py similarity index 99% rename from vocoder/fregan/generator.py rename to models/vocoder/fregan/generator.py index c0dd3a8..8f8eedf 100644 --- a/vocoder/fregan/generator.py +++ b/models/vocoder/fregan/generator.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 vocoder.fregan.utils import init_weights, get_padding +from models.vocoder.fregan.utils import init_weights, get_padding LRELU_SLOPE = 0.1 diff --git a/vocoder/fregan/inference.py b/models/vocoder/fregan/inference.py similarity index 97% rename from vocoder/fregan/inference.py rename to models/vocoder/fregan/inference.py index 780a613..e23a33b 100644 --- a/vocoder/fregan/inference.py +++ b/models/vocoder/fregan/inference.py @@ -4,7 +4,7 @@ import os import json import torch from utils.util import AttrDict -from vocoder.fregan.generator import FreGAN +from models.vocoder.fregan.generator import FreGAN generator = None # type: FreGAN output_sample_rate = None diff --git a/vocoder/fregan/loss.py b/models/vocoder/fregan/loss.py similarity index 100% rename from vocoder/fregan/loss.py rename to models/vocoder/fregan/loss.py diff --git a/vocoder/fregan/meldataset.py b/models/vocoder/fregan/meldataset.py similarity index 100% rename from vocoder/fregan/meldataset.py rename to models/vocoder/fregan/meldataset.py diff --git a/vocoder/fregan/modules.py b/models/vocoder/fregan/modules.py similarity index 100% rename from vocoder/fregan/modules.py rename to models/vocoder/fregan/modules.py diff --git a/vocoder/fregan/stft_loss.py b/models/vocoder/fregan/stft_loss.py similarity index 100% rename from vocoder/fregan/stft_loss.py rename to models/vocoder/fregan/stft_loss.py diff --git a/vocoder/fregan/train.py b/models/vocoder/fregan/train.py similarity index 96% rename from vocoder/fregan/train.py rename to models/vocoder/fregan/train.py index de1fac9..53025ca 100644 --- a/vocoder/fregan/train.py +++ b/models/vocoder/fregan/train.py @@ -10,11 +10,11 @@ from torch.utils.tensorboard import SummaryWriter from torch.utils.data import DistributedSampler, DataLoader from torch.distributed import init_process_group from torch.nn.parallel import DistributedDataParallel -from vocoder.fregan.meldataset import MelDataset, mel_spectrogram, get_dataset_filelist -from vocoder.fregan.generator import FreGAN -from vocoder.fregan.discriminator import ResWiseMultiPeriodDiscriminator, ResWiseMultiScaleDiscriminator -from vocoder.fregan.loss import feature_loss, generator_loss, discriminator_loss -from vocoder.fregan.utils import plot_spectrogram, scan_checkpoint, load_checkpoint, save_checkpoint +from models.vocoder.fregan.meldataset import MelDataset, mel_spectrogram, get_dataset_filelist +from models.vocoder.fregan.generator import FreGAN +from models.vocoder.fregan.discriminator import ResWiseMultiPeriodDiscriminator, ResWiseMultiScaleDiscriminator +from models.vocoder.fregan.loss import feature_loss, generator_loss, discriminator_loss +from models.vocoder.fregan.utils import plot_spectrogram, scan_checkpoint, load_checkpoint, save_checkpoint torch.backends.cudnn.benchmark = True diff --git a/vocoder/fregan/utils.py b/models/vocoder/fregan/utils.py similarity index 100% rename from vocoder/fregan/utils.py rename to models/vocoder/fregan/utils.py diff --git a/models/vocoder/hifigan/__init__.py b/models/vocoder/hifigan/__init__.py new file mode 100644 index 0000000..4287ca8 --- /dev/null +++ b/models/vocoder/hifigan/__init__.py @@ -0,0 +1 @@ +# \ No newline at end of file diff --git a/vocoder/hifigan/config_16k_.json b/models/vocoder/hifigan/config_16k_.json similarity index 100% rename from vocoder/hifigan/config_16k_.json rename to models/vocoder/hifigan/config_16k_.json diff --git a/vocoder/hifigan/env.py b/models/vocoder/hifigan/env.py similarity index 100% rename from vocoder/hifigan/env.py rename to models/vocoder/hifigan/env.py diff --git a/vocoder/hifigan/inference.py b/models/vocoder/hifigan/inference.py similarity index 97% rename from vocoder/hifigan/inference.py rename to models/vocoder/hifigan/inference.py index 8caf348..d98e4b8 100644 --- a/vocoder/hifigan/inference.py +++ b/models/vocoder/hifigan/inference.py @@ -4,7 +4,7 @@ import os import json import torch from utils.util import AttrDict -from vocoder.hifigan.models import Generator +from models.vocoder.hifigan.models import Generator generator = None # type: Generator output_sample_rate = None diff --git a/vocoder/hifigan/meldataset.py b/models/vocoder/hifigan/meldataset.py similarity index 100% rename from vocoder/hifigan/meldataset.py rename to models/vocoder/hifigan/meldataset.py diff --git a/vocoder/hifigan/models.py b/models/vocoder/hifigan/models.py similarity index 99% rename from vocoder/hifigan/models.py rename to models/vocoder/hifigan/models.py index c352e19..fc46164 100644 --- a/vocoder/hifigan/models.py +++ b/models/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 vocoder.hifigan.utils import init_weights, get_padding +from models.vocoder.hifigan.utils import init_weights, get_padding LRELU_SLOPE = 0.1 diff --git a/vocoder/hifigan/train.py b/models/vocoder/hifigan/train.py similarity index 97% rename from vocoder/hifigan/train.py rename to models/vocoder/hifigan/train.py index 7e9c2f2..a2559b9 100644 --- a/vocoder/hifigan/train.py +++ b/models/vocoder/hifigan/train.py @@ -12,10 +12,10 @@ from torch.utils.data import DistributedSampler, DataLoader import torch.multiprocessing as mp from torch.distributed import init_process_group from torch.nn.parallel import DistributedDataParallel -from vocoder.hifigan.meldataset import MelDataset, mel_spectrogram, get_dataset_filelist -from vocoder.hifigan.models import Generator, MultiPeriodDiscriminator, MultiScaleDiscriminator, feature_loss, generator_loss,\ +from models.vocoder.hifigan.meldataset import MelDataset, mel_spectrogram, get_dataset_filelist +from models.vocoder.hifigan.models import Generator, MultiPeriodDiscriminator, MultiScaleDiscriminator, feature_loss, generator_loss,\ discriminator_loss -from vocoder.hifigan.utils import plot_spectrogram, scan_checkpoint, load_checkpoint, save_checkpoint +from models.vocoder.hifigan.utils import plot_spectrogram, scan_checkpoint, load_checkpoint, save_checkpoint torch.backends.cudnn.benchmark = True diff --git a/vocoder/hifigan/utils.py b/models/vocoder/hifigan/utils.py similarity index 100% rename from vocoder/hifigan/utils.py rename to models/vocoder/hifigan/utils.py diff --git a/vocoder/vocoder_dataset.py b/models/vocoder/vocoder_dataset.py similarity index 98% rename from vocoder/vocoder_dataset.py rename to models/vocoder/vocoder_dataset.py index 3aedb09..f79f3bf 100644 --- a/vocoder/vocoder_dataset.py +++ b/models/vocoder/vocoder_dataset.py @@ -1,6 +1,6 @@ from torch.utils.data import Dataset from pathlib import Path -from vocoder.wavernn import audio +from models.vocoder.wavernn import audio import vocoder.wavernn.hparams as hp import numpy as np import torch diff --git a/vocoder/wavernn/audio.py b/models/vocoder/wavernn/audio.py similarity index 100% rename from vocoder/wavernn/audio.py rename to models/vocoder/wavernn/audio.py diff --git a/vocoder/wavernn/gen_wavernn.py b/models/vocoder/wavernn/gen_wavernn.py similarity index 89% rename from vocoder/wavernn/gen_wavernn.py rename to models/vocoder/wavernn/gen_wavernn.py index abda3eb..d5baed9 100644 --- a/vocoder/wavernn/gen_wavernn.py +++ b/models/vocoder/wavernn/gen_wavernn.py @@ -1,5 +1,5 @@ -from vocoder.wavernn.models.fatchord_version import WaveRNN -from vocoder.wavernn.audio import * +from models.vocoder.wavernn.models.fatchord_version import WaveRNN +from models.vocoder.wavernn.audio import * def gen_testset(model: WaveRNN, test_set, samples, batched, target, overlap, save_path): diff --git a/vocoder/wavernn/hparams.py b/models/vocoder/wavernn/hparams.py similarity index 96% rename from vocoder/wavernn/hparams.py rename to models/vocoder/wavernn/hparams.py index c1de9f7..31f3966 100644 --- a/vocoder/wavernn/hparams.py +++ b/models/vocoder/wavernn/hparams.py @@ -1,4 +1,4 @@ -from synthesizer.hparams import hparams as _syn_hp +from models.synthesizer.hparams import hparams as _syn_hp # Audio settings------------------------------------------------------------------------ diff --git a/vocoder/wavernn/inference.py b/models/vocoder/wavernn/inference.py similarity index 93% rename from vocoder/wavernn/inference.py rename to models/vocoder/wavernn/inference.py index 40cd305..b8742d5 100644 --- a/vocoder/wavernn/inference.py +++ b/models/vocoder/wavernn/inference.py @@ -1,5 +1,5 @@ -from vocoder.wavernn.models.fatchord_version import WaveRNN -from vocoder.wavernn import hparams as hp +from models.vocoder.wavernn.models.fatchord_version import WaveRNN +from models.vocoder.wavernn import hparams as hp import torch diff --git a/vocoder/wavernn/models/deepmind_version.py b/models/vocoder/wavernn/models/deepmind_version.py similarity index 100% rename from vocoder/wavernn/models/deepmind_version.py rename to models/vocoder/wavernn/models/deepmind_version.py diff --git a/vocoder/wavernn/models/fatchord_version.py b/models/vocoder/wavernn/models/fatchord_version.py similarity index 98% rename from vocoder/wavernn/models/fatchord_version.py rename to models/vocoder/wavernn/models/fatchord_version.py index 6413a92..335bb3b 100644 --- a/vocoder/wavernn/models/fatchord_version.py +++ b/models/vocoder/wavernn/models/fatchord_version.py @@ -1,9 +1,9 @@ import torch 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.wavernn.audio import * +from models.vocoder.distribution import sample_from_discretized_mix_logistic +from models.vocoder.display import * +from models.vocoder.wavernn.audio import * class ResBlock(nn.Module): diff --git a/vocoder/wavernn/train.py b/models/vocoder/wavernn/train.py similarity index 93% rename from vocoder/wavernn/train.py rename to models/vocoder/wavernn/train.py index 44e0929..e0fdb1b 100644 --- a/vocoder/wavernn/train.py +++ b/models/vocoder/wavernn/train.py @@ -1,8 +1,8 @@ -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.wavernn.gen_wavernn import gen_testset +from models.vocoder.wavernn.models.fatchord_version import WaveRNN +from models.vocoder.vocoder_dataset import VocoderDataset, collate_vocoder +from models.vocoder.distribution import discretized_mix_logistic_loss +from models.vocoder.display import stream, simple_table +from models.vocoder.wavernn.gen_wavernn import gen_testset from torch.utils.data import DataLoader from pathlib import Path from torch import optim diff --git a/pre.py b/pre.py index 17fd0f7..dd9a2b5 100644 --- a/pre.py +++ b/pre.py @@ -1,10 +1,10 @@ -from synthesizer.preprocess import create_embeddings +from models.synthesizer.preprocess import create_embeddings from utils.argutils import print_args from pathlib import Path import argparse -from synthesizer.preprocess import preprocess_dataset -from synthesizer.hparams import hparams +from models.synthesizer.preprocess import preprocess_dataset +from models.synthesizer.hparams import hparams from utils.argutils import print_args from pathlib import Path import argparse diff --git a/run.py b/run.py index 170f9db..904029a 100644 --- a/run.py +++ b/run.py @@ -6,15 +6,15 @@ import numpy as np import glob from pathlib import Path from tqdm import tqdm -from ppg_extractor import load_model +from models.ppg_extractor import load_model import librosa import soundfile as sf from utils.load_yaml import HpsYaml -from encoder.audio import preprocess_wav -from encoder import inference as speacker_encoder -from vocoder.hifigan import inference as vocoder -from ppg2mel import MelDecoderMOLv2 +from models.encoder.audio import preprocess_wav +from models.encoder import inference as speacker_encoder +from models.vocoder.hifigan import inference as vocoder +from models.ppg2mel import MelDecoderMOLv2 from utils.f0_utils import compute_f0, f02lf0, compute_mean_std, get_converted_lf0uv diff --git a/train.py b/train.py index 5a6a06c..557bc26 100644 --- a/train.py +++ b/train.py @@ -3,7 +3,7 @@ import torch import argparse import numpy as np from utils.load_yaml import HpsYaml -from ppg2mel.train.train_linglf02mel_seq2seq_oneshotvc import Solver +from models.ppg2mel.train.train_linglf02mel_seq2seq_oneshotvc import Solver # For reproducibility, comment these may speed up training torch.backends.cudnn.deterministic = True diff --git a/vocoder/saved_models/pretrained/g_hifigan.pt b/vocoder/saved_models/pretrained/g_hifigan.pt deleted file mode 100644 index 5d8d2c0..0000000 Binary files a/vocoder/saved_models/pretrained/g_hifigan.pt and /dev/null differ diff --git a/vocoder/saved_models/pretrained/pretrained.pt b/vocoder/saved_models/pretrained/pretrained.pt deleted file mode 100644 index ee2d5cf..0000000 Binary files a/vocoder/saved_models/pretrained/pretrained.pt and /dev/null differ diff --git a/web.py b/web.py index e478a67..aad9a3f 100644 --- a/web.py +++ b/web.py @@ -14,7 +14,7 @@ def launch(port: int = typer.Option(8080, "--port", "-p")) -> None: # This is required to resolve the opyrator path sys.path.append(os.getcwd()) - from mkgui.base.ui.streamlit_ui import launch_ui + from control.mkgui.base.ui.streamlit_ui import launch_ui launch_ui(port) if __name__ == "__main__": diff --git a/web/DOCKERFILE b/web/DOCKERFILE deleted file mode 100644 index 64e8c53..0000000 --- a/web/DOCKERFILE +++ /dev/null @@ -1,10 +0,0 @@ - -FROM python:3.7 - -RUN pip install gevent uwsgi flask - -COPY app.py /app.py - -EXPOSE 3000 - -ENTRYPOINT ["uwsgi", "--http", ":3000", "--master", "--module", "app:app"] \ No newline at end of file diff --git a/web/__init__.py b/web/__init__.py deleted file mode 100644 index 0b71aa5..0000000 --- a/web/__init__.py +++ /dev/null @@ -1,135 +0,0 @@ -from web.api import api_blueprint -from pathlib import Path -from gevent import pywsgi as wsgi -from flask import Flask, Response, request, render_template -from synthesizer.inference import Synthesizer -from encoder import inference as encoder -from vocoder.hifigan import inference as gan_vocoder -from vocoder.wavernn import inference as rnn_vocoder -import numpy as np -import re -from scipy.io.wavfile import write -import librosa -import io -import base64 -from flask_cors import CORS -from flask_wtf import CSRFProtect -import webbrowser - -def webApp(): - # Init and load config - app = Flask(__name__, instance_relative_config=True) - app.config.from_object("web.config.default") - app.config['RESTPLUS_MASK_SWAGGER'] = False - app.register_blueprint(api_blueprint) - - # CORS(app) #允许跨域,注释掉此行则禁止跨域请求 - csrf = CSRFProtect(app) - csrf.init_app(app) - - syn_models_dirt = "synthesizer/saved_models" - synthesizers = list(Path(syn_models_dirt).glob("**/*.pt")) - synthesizers_cache = {} - encoder.load_model(Path("encoder/saved_models/pretrained.pt")) - rnn_vocoder.load_model(Path("vocoder/saved_models/pretrained/pretrained.pt")) - gan_vocoder.load_model(Path("vocoder/saved_models/pretrained/g_hifigan.pt")) - - def pcm2float(sig, dtype='float32'): - """Convert PCM signal to floating point with a range from -1 to 1. - Use dtype='float32' for single precision. - Parameters - ---------- - sig : array_like - Input array, must have integral type. - dtype : data type, optional - Desired (floating point) data type. - Returns - ------- - numpy.ndarray - Normalized floating point data. - See Also - -------- - float2pcm, dtype - """ - sig = np.asarray(sig) - if sig.dtype.kind not in 'iu': - raise TypeError("'sig' must be an array of integers") - dtype = np.dtype(dtype) - if dtype.kind != 'f': - raise TypeError("'dtype' must be a floating point type") - - i = np.iinfo(sig.dtype) - abs_max = 2 ** (i.bits - 1) - offset = i.min + abs_max - return (sig.astype(dtype) - offset) / abs_max - - # Cache for synthesizer - @csrf.exempt - @app.route("/api/synthesize", methods=["POST"]) - def synthesize(): - # TODO Implementation with json to support more platform - # Load synthesizer - if "synt_path" in request.form: - synt_path = request.form["synt_path"] - else: - synt_path = synthesizers[0] - print("NO synthsizer is specified, try default first one.") - if synthesizers_cache.get(synt_path) is None: - current_synt = Synthesizer(Path(synt_path)) - synthesizers_cache[synt_path] = current_synt - else: - current_synt = synthesizers_cache[synt_path] - print("using synthesizer model: " + str(synt_path)) - # Load input wav - if "upfile_b64" in request.form: - wav_base64 = request.form["upfile_b64"] - wav = base64.b64decode(bytes(wav_base64, 'utf-8')) - wav = pcm2float(np.frombuffer(wav, dtype=np.int16), dtype=np.float32) - sample_rate = Synthesizer.sample_rate - else: - wav, sample_rate, = librosa.load(request.files['file']) - write("temp.wav", sample_rate, wav) #Make sure we get the correct wav - - encoder_wav = encoder.preprocess_wav(wav, sample_rate) - embed, _, _ = encoder.embed_utterance(encoder_wav, return_partials=True) - - # Load input text - texts = filter(None, request.form["text"].split("\n")) - punctuation = '!,。、,' # punctuate and split/clean text - processed_texts = [] - for text in texts: - for processed_text in re.sub(r'[{}]+'.format(punctuation), '\n', text).split('\n'): - if processed_text: - processed_texts.append(processed_text.strip()) - texts = processed_texts - - # synthesize and vocode - embeds = [embed] * len(texts) - specs = current_synt.synthesize_spectrograms(texts, embeds) - spec = np.concatenate(specs, axis=1) - sample_rate = Synthesizer.sample_rate - if "vocoder" in request.form and request.form["vocoder"] == "WaveRNN": - wav, sample_rate = rnn_vocoder.infer_waveform(spec) - else: - wav, sample_rate = gan_vocoder.infer_waveform(spec) - - # Return cooked wav - out = io.BytesIO() - write(out, sample_rate, wav.astype(np.float32)) - return Response(out, mimetype="audio/wav") - - @app.route('/', methods=['GET']) - def index(): - return render_template("index.html") - - host = app.config.get("HOST") - port = app.config.get("PORT") - web_address = 'http://{}:{}'.format(host, port) - print(f"Web server:" + web_address) - webbrowser.open(web_address) - server = wsgi.WSGIServer((host, port), app) - server.serve_forever() - return app - -if __name__ == "__main__": - webApp() diff --git a/web/api/__init__.py b/web/api/__init__.py deleted file mode 100644 index a0c8726..0000000 --- a/web/api/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -from flask import Blueprint -from flask_restx import Api -from .audio import api as audio -from .synthesizer import api as synthesizer - -api_blueprint = Blueprint('api', __name__, url_prefix='/api') - -api = Api( - app=api_blueprint, - title='Mocking Bird', - version='1.0', - description='My API' -) - -api.add_namespace(audio) -api.add_namespace(synthesizer) \ No newline at end of file diff --git a/web/api/audio.py b/web/api/audio.py deleted file mode 100644 index b30e5dd..0000000 --- a/web/api/audio.py +++ /dev/null @@ -1,43 +0,0 @@ -import os -from pathlib import Path -from flask_restx import Namespace, Resource, fields -from flask import Response, current_app - -api = Namespace('audios', description='Audios related operations') - -audio = api.model('Audio', { - 'name': fields.String(required=True, description='The audio name'), -}) - -def generate(wav_path): - with open(wav_path, "rb") as fwav: - data = fwav.read(1024) - while data: - yield data - data = fwav.read(1024) - -@api.route('/') -class AudioList(Resource): - @api.doc('list_audios') - @api.marshal_list_with(audio) - def get(self): - '''List all audios''' - audio_samples = [] - AUDIO_SAMPLES_DIR = current_app.config.get("AUDIO_SAMPLES_DIR") - if os.path.isdir(AUDIO_SAMPLES_DIR): - audio_samples = list(Path(AUDIO_SAMPLES_DIR).glob("*.wav")) - return list(a.name for a in audio_samples) - -@api.route('/') -@api.param('name', 'The name of audio') -@api.response(404, 'audio not found') -class Audio(Resource): - @api.doc('get_audio') - @api.marshal_with(audio) - def get(self, name): - '''Fetch a cat given its identifier''' - AUDIO_SAMPLES_DIR = current_app.config.get("AUDIO_SAMPLES_DIR") - if Path(AUDIO_SAMPLES_DIR + name).exists(): - return Response(generate(AUDIO_SAMPLES_DIR + name), mimetype="audio/x-wav") - api.abort(404) - \ No newline at end of file diff --git a/web/api/synthesizer.py b/web/api/synthesizer.py deleted file mode 100644 index 23963b3..0000000 --- a/web/api/synthesizer.py +++ /dev/null @@ -1,23 +0,0 @@ -from pathlib import Path -from flask_restx import Namespace, Resource, fields - -api = Namespace('synthesizers', description='Synthesizers related operations') - -synthesizer = api.model('Synthesizer', { - 'name': fields.String(required=True, description='The synthesizer name'), - 'path': fields.String(required=True, description='The synthesizer path'), -}) - -synthesizers_cache = {} -syn_models_dirt = "synthesizer/saved_models" -synthesizers = list(Path(syn_models_dirt).glob("**/*.pt")) -print("Loaded synthesizer models: " + str(len(synthesizers))) - -@api.route('/') -class SynthesizerList(Resource): - @api.doc('list_synthesizers') - @api.marshal_list_with(synthesizer) - def get(self): - '''List all synthesizers''' - return list({"name": e.name, "path": str(e)} for e in synthesizers) - diff --git a/web/config/default.py b/web/config/default.py deleted file mode 100644 index 02149ab..0000000 --- a/web/config/default.py +++ /dev/null @@ -1,8 +0,0 @@ -AUDIO_SAMPLES_DIR = 'samples\\' -DEVICE = '0' -HOST = 'localhost' -PORT = 8080 -MAX_CONTENT_PATH =1024 * 1024 * 4 # mp3文件大小限定不能超过4M -SECRET_KEY = "mockingbird_key" -WTF_CSRF_SECRET_KEY = "mockingbird_key" -TEMPLATES_AUTO_RELOAD = True \ No newline at end of file diff --git a/web/static/img/bird-sm.png b/web/static/img/bird-sm.png deleted file mode 100644 index d94ab43..0000000 Binary files a/web/static/img/bird-sm.png and /dev/null differ diff --git a/web/static/img/bird.png b/web/static/img/bird.png deleted file mode 100644 index fc02771..0000000 Binary files a/web/static/img/bird.png and /dev/null differ diff --git a/web/static/img/mockingbird.png b/web/static/img/mockingbird.png deleted file mode 100644 index 9feaf86..0000000 Binary files a/web/static/img/mockingbird.png and /dev/null differ diff --git a/web/static/js/eruda.min.js b/web/static/js/eruda.min.js deleted file mode 100644 index 0609b9e..0000000 --- a/web/static/js/eruda.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! eruda v1.5.4 https://eruda.liriliri.io/ */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.eruda=t():e.eruda=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/assets/",t(t.s=82)}([function(e,t,n){"use strict";(function(e,r){function i(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.wrap=t.viewportScale=t.unique=t.uniqId=t.tryIt=t.stripHtmlTag=t.LocalStore=t.stringify=t.type=t.ajax=t.Url=t.query=t.getFileName=t.trim=t.rtrim=t.rmCookie=t.pxToNum=t.perfNow=t.orientation=t.Store=t.Logger=t.Emitter=t.once=t.partial=t.restArgs=t.now=t.nextTick=t.detectBrowser=t.toInt=t.ms=t.toNum=t.meta=t.safeStorage=t.memStorage=t.$=t.$class=t.some=t.cloneDeep=t.mapObj=void 0,t.concat=t.$event=t.delegate=t.$show=t.$remove=t.$property=t.$offset=t.$insert=t.$css=t.$data=t.$attr=t.$safeEls=t.Select=t.MutationObserver=t.Enum=t.Class=t.toArr=t.cookie=t.decodeUriComponent=t.map=t.evalCss=t.filter=t.safeCb=t.matcher=t.ltrim=t.dateFormat=t.lpad=t.repeat=t.loadJs=t.isRegExp=t.isNull=t.isNative=t.toSrc=t.isNil=t.isNaN=t.prefix=t.isMobile=t.memoize=t.isMatch=t.isErudaEl=t.isErr=t.isEl=t.isCrossOrig=t.startWith=t.isBool=t.isEmpty=t.isStr=t.contain=t.values=t.extendOwn=t.clone=t.extend=t.defaults=t.createAssigner=t.each=t.isArrLike=t.isNum=t.isMiniProgram=t.isFn=t.isDate=t.safeGet=t.castPath=t.isArr=t.isArgs=t.objToStr=t.identity=t.getObjType=t.upperFirst=t.fullUrl=t.fileSize=t.escapeRegExp=t.escapeJsonStr=t.escapeJsStr=t.escape=t.endWith=t.optimizeCb=t.detectOs=t.freeze=t.keys=t.detectMocha=t.root=t.utf8=t.ucs2=t.toStr=t.idxOf=t.clamp=t.chunk=t.kebabCase=t.camelCase=t.splitCase=t.before=t.allKeys=t.noop=t.isBrowser=t.slice=t.has=t.inherits=t.isObj=t.isUndef=t.last=void 0;var o=n(28),a=i(o),s=n(123),u=i(s),l=n(66),c=i(l),d=n(34),f=i(d),p=n(130),h=i(p),v=n(35),g=i(v),m=n(135),_=i(m),b=n(73),y=i(b),x=n(25),w=i(x),k={},E=k.last=function(){function e(e){var t=e?e.length:0;if(t)return e[t-1]}return e}();t.last=E;var S=t.isUndef=k.isUndef=function(){function e(e){return void 0===e}return e}(),T=t.isObj=k.isObj=function(){function e(e){var t=void 0===e?"undefined":(0,w.default)(e);return!!e&&("function"===t||"object"===t)}return e}(),O=t.inherits=k.inherits=function(){function e(e,r){if(n)return e.prototype=n(r.prototype);t.prototype=r.prototype,e.prototype=new t}function t(){}var n=y.default;return e}(),A=t.has=k.has=function(){function e(e,n){return t.call(e,n)}var t=Object.prototype.hasOwnProperty;return e}(),C=t.slice=k.slice=function(){function e(e,t,n){var r=e.length;t=null==t?0:t<0?Math.max(r+t,0):Math.min(t,r),n=null==n?r:n<0?Math.max(r+n,0):Math.min(n,r);for(var i=[];t0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}}return e}(),L=t.splitCase=k.splitCase=function(){function e(e){return e=e.replace(t,"-$1").toLowerCase().replace(n,"-").replace(r,""),e.split("-")}var t=/([A-Z])/g,n=/[_.\- ]+/g,r=/(^-)|(-$)/g;return e}(),N=t.camelCase=k.camelCase=function(){function e(e){var n=L(e),r=n[0];return n.shift(),n.forEach(t,n),r+=n.join("")}function t(e,t){this[t]=e.replace(/\w/,function(e){return e.toUpperCase()})}return e}(),D=t.kebabCase=k.kebabCase=function(){function e(e){return L(e).join("-")}return e}(),I=(t.chunk=k.chunk=function(){function e(e,t){var n=[];t=t||1;for(var r=0,i=Math.ceil(e.length/t);rn?n:e}return e}()),K=t.idxOf=k.idxOf=function(){function e(e,t,n){return Array.prototype.indexOf.call(e,t,n)}return e}(),z=t.toStr=k.toStr=function(){function e(e){return null==e?"":e.toString()}return e}(),F=t.ucs2=k.ucs2=function(e){return{encode:function(e){return _.default.apply(String,e)},decode:function(e){for(var t=[],n=0,r=e.length;n=55296&&i<=56319&&n>6*t)+n);t>0;){r+=f(128|63&e>>6*(t-1)),t--}return r}function n(e){for(;;){if(o>=a&&l){if(e)return r();throw new Error("Invalid byte index")}if(o===a)return!1;var t=i[o];if(o++,l){if(td){if(e)return o--,r();throw new Error("Invalid continuation byte")}if(c=128,d=191,s=s<<6|63&t,++u===l){var n=s;return s=0,l=0,u=0,n}}else{if(0==(128&t))return t;if(192==(224&t))l=1,s=31&t;else if(224==(240&t))224===t&&(c=160),237===t&&(d=159),l=2,s=15&t;else{if(240!=(248&t)){if(e)return r();throw new Error("Invalid UTF-8 detected")}240===t&&(c=144),244===t&&(d=143),l=3,s=7&t}}}}function r(){var e=o-u-1;return o=e+1,s=0,l=0,u=0,c=128,d=191,i[e]}e={encode:function(e){for(var n=F.decode(e),r="",i=0,o=n.length;i-1}return e=e||(j?navigator.userAgent:""),e=e.toLowerCase(),t("windows phone")?"windows phone":t("win")?"windows":t("android")?"android":t("ipad")||t("iphone")||t("ipod")?"ios":t("mac")?"os x":t("linux")?"linux":"unknown"}return e}(),t.optimizeCb=k.optimizeCb=function(){function e(e,t,n){if(S(t))return e;switch(null==n?3:n){case 1:return function(n){return e.call(t,n)};case 3:return function(n,r,i){return e.call(t,n,r,i)};case 4:return function(n,r,i,o){return e.call(t,n,r,i,o)}}return function(){return e.apply(t,arguments)}}return e}()),G=(t.endWith=k.endWith=function(){function e(e,t){var n=e.length-t.length;return n>=0&&e.indexOf(t,n)===n}return e}(),t.escape=k.escape=function(){function e(e){return i.test(e)?e.replace(o,t):e}function t(e){return n[e]}var n=e.map={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},r="(?:"+U(n).join("|")+")",i=new RegExp(r),o=new RegExp(r,"g");return e}(),t.escapeJsStr=k.escapeJsStr=function(){function e(e){return z(e).replace(t,function(e){switch(e){case'"':case"'":case"\\":return"\\"+e;case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029"}})}var t=/["'\\\n\r\u2028\u2029]/g;return e}()),q=(t.escapeJsonStr=k.escapeJsonStr=function(){function e(e){return G(e).replace(/\\'/g,"'").replace(/\t/g,"\\t")}return e}(),t.escapeRegExp=k.escapeRegExp=function(){function e(e){return e.replace(/\W/g,"\\$&")}return e}(),t.fileSize=k.fileSize=function(){function e(e){if(e<=0)return"0";var n=Math.floor(Math.log(e)/Math.log(1024));return+(e/Math.pow(2,10*n)).toFixed(2)+t[n]}var t=["","K","M","G","T"];return e}(),t.fullUrl=k.fullUrl=function(){function e(e){return t.href=e,t.protocol+"//"+t.host+t.pathname+t.search+t.hash}var t=document.createElement("a");return e}(),t.upperFirst=k.upperFirst=function(){function e(e){return e.length<1?e:e[0].toUpperCase()+e.slice(1)}return e}()),J=(t.getObjType=k.getObjType=function(){function e(e){return e.constructor&&e.constructor.name?e.constructor.name:q({}.toString.call(e).replace(/(\[object )|]/g,""))}return e}(),t.identity=k.identity=function(){function e(e){return e}return e}()),Y=t.objToStr=k.objToStr=function(){function e(e){return t.call(e)}var t=Object.prototype.toString;return e}(),Q=t.isArgs=k.isArgs=function(){function e(e){return"[object Arguments]"===Y(e)}return e}(),X=t.isArr=k.isArr=function(e){return Array.isArray||function(e){return"[object Array]"===Y(e)}}(),Z=t.castPath=k.castPath=function(){function e(e,r){if(X(e))return e;if(r&&A(r,e))return[e];var i=[];return e.replace(t,function(e,t,r,o){i.push(r?o.replace(n,"$1"):t||e)}),i}var t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g;return e}(),ee=t.safeGet=k.safeGet=function(){function e(e,t){t=Z(t,e);var n;for(n=t.shift();!S(n);){if(null==(e=e[n]))return;n=t.shift()}return e}return e}(),te=t.isDate=k.isDate=function(){function e(e){return"[object Date]"===Y(e)}return e}(),ne=t.isFn=k.isFn=function(){function e(e){var t=Y(e);return"[object Function]"===t||"[object GeneratorFunction]"===t}return e}(),re=t.isMiniProgram=k.isMiniProgram=function(e){return"undefined"!=typeof wx&&ne(wx.openLocation)}(),ie=t.isNum=k.isNum=function(){function e(e){return"[object Number]"===Y(e)}return e}(),oe=t.isArrLike=k.isArrLike=function(){function e(e){if(!e)return!1;var n=e.length;return ie(n)&&n>=0&&n<=t&&!ne(e)}var t=Math.pow(2,53)-1;return e}(),ae=k.each=function(){function e(e,t,n){t=W(t,n);var r,i;if(oe(e))for(r=0,i=e.length;r=0}return e}(),he=t.isStr=k.isStr=function(){function e(e){return"[object String]"===Y(e)}return e}(),ve=t.isEmpty=k.isEmpty=function(){function e(e){return null==e||(oe(e)&&(X(e)||he(e)||Q(e))?0===e.length:0===U(e).length)}return e}(),ge=(t.isBool=k.isBool=function(){function e(e){return!0===e||!1===e}return e}(),t.startWith=k.startWith=function(){function e(e,t){return 0===e.indexOf(t)}return e}()),me=(t.isCrossOrig=k.isCrossOrig=function(){function e(e){return!ge(e,t)}var t=window.location.origin;return e}(),t.isEl=k.isEl=function(){function e(e){return!(!e||1!==e.nodeType)}return e}(),t.isErr=k.isErr=function(){function e(e){return"[object Error]"===Y(e)}return e}(),t.isErudaEl=k.isErudaEl=function(){function e(e){var t=e.parentNode;if(!t)return!1;for(;t;)if((t=t.parentNode)&&"eruda"===t.id)return!0;return!1}return e}(),t.isMatch=k.isMatch=function(){function e(e,t){var n=U(t),r=n.length;if(null==e)return!r;e=Object(e);for(var i=0;i0;)1&t&&(n+=e),t>>=1,e+=e;return n}}()),Se=t.lpad=k.lpad=function(){function e(e,t,n){e=z(e);var r=e.length;return n=n||" ",r0?"-":"+")+t(100*Math.floor(Math.abs(y)/60)+Math.abs(y)%60,4),S:["th","st","nd","rd"][f%10>3?0:(f%100-f%10!=10)*f%10]};return s.replace(n,function(e){return e in x?x[e]:e.slice(1,e.length-1)})}function t(e,t){return Se(z(e),t||2,"0")}var n=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZWN]|'[^']*'|'[^']*'/g,r=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,i=/\d/,o=/[^-+\dA-Z]/g;return e.masks={default:"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:sso",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'",expiresHeaderFormat:"ddd, dd mmm yyyy HH:MM:ss Z"},e.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]},e}(),t.ltrim=k.ltrim=function(){function e(e,n){if(null==n)return e.replace(t,"");for(var r,i,o=0,a=e.length,s=n.length,u=!0;u&&o=a?"":e.substr(o,a)}var t=/^\s+/;return e}()),Oe=t.matcher=k.matcher=function(){function e(e){return e=de({},e),function(t){return me(t,e)}}return e}(),Ae=t.safeCb=k.safeCb=function(e){return function(e,t,n){return null==e?J:ne(e)?W(e,t,n):T(e)?Oe(e):function(e){return function(t){return null==t?void 0:t[e]}}}}(),Ce=t.filter=k.filter=function(){function e(e,t,n){var r=[];return t=Ae(t,n),ae(e,function(e,n,i){t(e,n,i)&&r.push(e)}),r}return e}(),je=(t.evalCss=k.evalCss=function(){function e(r,i){r=z(r);for(var o=0,a=n.length;o=0&&e=t[n[s]]){a=n[s];break}return+(o/t[a]).toFixed(2)+a}var t={ms:1,s:1e3};t.m=60*t.s,t.h=60*t.m,t.d=24*t.h,t.y=365.25*t.d;var n=["y","d","h","m","s"],r=/^((?:\d+)?\.?\d+) *(s|m|h|d|y)?$/;return e}(),t.toInt=k.toInt=function(){function e(e){return e?(e=et(e))-e%1:0===e?e:0}return e}()),nt=(t.detectBrowser=k.detectBrowser=function(){function e(e){e=e||(j?navigator.userAgent:""),e=e.toLowerCase();var o=t(e,"msie ");if(o)return{version:o,name:"ie"};if(r.test(e))return{version:11,name:"ie"};for(var a=0,s=i.length;a-1)return tt(e.substring(n+t.length,e.indexOf(".",n)))}var n={edge:/edge\/([0-9._]+)/,firefox:/firefox\/([0-9.]+)(?:\s|$)/,opera:/opera\/([0-9.]+)(?:\s|$)/,android:/android\s([0-9.]+)/,ios:/version\/([0-9._]+).*mobile.*safari.*/,safari:/version\/([0-9._]+).*safari/,chrome:/(?!chrom.*opr)chrom(?:e|ium)\/([0-9.]+)(:?\s|$)/},r=/trident\/7\./,i=U(n);return e}(),t.nextTick=k.nextTick=function(e){function t(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}return"object"===(void 0===r?"undefined":(0,w.default)(r))&&r.nextTick?r.nextTick:"function"==typeof u.default?function(e){(0,u.default)(t(e))}:function(e){setTimeout(t(e),0)}}(),t.now=k.now=function(e){return Date.now||function(){return(new Date).getTime()}}()),rt=t.restArgs=k.restArgs=function(){function e(e,t){return t=null==t?e.length-1:+t,function(){var n,r=Math.max(arguments.length-t,0),i=new Array(r);for(n=0;nwindow.innerHeight?"landscape":"portrait"}},at.mixin(e),window.addEventListener("orientationchange",function(){setTimeout(function(){e.emit("change",e.get())},200)},!1),e}({}),t.perfNow=k.perfNow=function(e){var t,n=H.performance,r=H.process;if(n&&n.now)e=function(){return n.now()};else if(r&&r.hrtime){var i=function(){var e=r.hrtime();return 1e9*e[0]+e[1]};t=i()-1e9*r.uptime(),e=function(){return(i()-t)/1e6}}else t=nt(),e=function(){return nt()-t};return e}({}),t.pxToNum=k.pxToNum=function(){function e(e){return et(e.replace("px",""))}return e}(),t.rmCookie=k.rmCookie=function(){function e(e){function t(t){return t=t||{},Pe.remove(e,t),!Pe.get(e)}var n,r=window.location,i=r.hostname,o=r.pathname,a=i.split("."),s=o.split("/"),u="",l=s.length;if(!t())for(var c=a.length-1;c>=0;c--){var d=a[c];if(""!==d){if(u=""===u?d:d+"."+u,n="/",t({domain:u,path:n})||t({domain:u}))return;for(var f=0;f=0;)for(s=!1,r=-1,i=e.charAt(o);++r=0?e.substring(0,o+1):""}var t=/\s+$/;return e}()),lt=t.trim=k.trim=function(){function e(e,n){return null==n?e.replace(t,""):Te(ut(e,n),n)}var t=/^\s+|\s+$/g;return e}(),ct=(t.getFileName=k.getFileName=function(){function e(e){var t=E(e.split("/"));return t.indexOf("?")>-1&&(t=lt(t.split("?")[0])),""===t?"unknown":t}return e}(),t.query=k.query=function(e){e={parse:function(e){var n={};return e=lt(e).replace(t,""),ae(e.split("&"),function(e){var t=e.split("="),r=t.shift(),i=t.length>0?t.join("="):null;r=decodeURIComponent(r),i=decodeURIComponent(i),S(n[r])?n[r]=i:X(n[r])?n[r].push(i):n[r]=[n[r],i]}),n},stringify:function(t,n){return Ce(je(t,function(t,r){return T(t)&&ve(t)?"":X(t)?e.stringify(t,r):(n?encodeURIComponent(n):encodeURIComponent(r))+"="+encodeURIComponent(t)}),function(e){return e.length>0}).join("&")}};var t=/^(\?|#|&)/g;return e}({})),dt=(t.Url=k.Url=function(e){e=Le({className:"Url",initialize:function(t){!t&&j&&(t=window.location.href),le(this,e.parse(t||""))},setQuery:function(e,t){var n=this.query;return T(e)?ae(e,function(e,t){n[t]=e}):n[e]=t,this},rmQuery:function(e){var t=this.query;return X(e)||(e=Re(e)),ae(e,function(e){delete t[e]}),this},toString:function(){return e.stringify(this)}},{parse:function(e){var i={protocol:"",auth:"",hostname:"",hash:"",query:{},port:"",pathname:"",slashes:!1},o=lt(e),a=o.match(t);if(a&&(a=a[0],i.protocol=a.toLowerCase(),o=o.substr(a.length)),a){var s="//"===o.substr(0,2);s&&(o=o.slice(2),i.slashes=!0)}if(s){for(var u=-1,l=0,c=r.length;l=200&&t<300||304===t){e=f.responseText,"xml"===s&&(e=f.responseXML);try{"json"===s&&(e=JSON.parse(e))}catch(e){}u(e,f)}else l(f);d(f)}},"GET"===r?(o=ct.stringify(o),i+=i.indexOf("?")>-1?"&"+o:"?"+o):"application/x-www-form-urlencoded"===t.contentType?T(o)&&(o=ct.stringify(o)):"application/json"===t.contentType&&T(o)&&(o=(0,a.default)(o)),f.open(r,i,!0),f.setRequestHeader("Content-Type",t.contentType),c>0&&(n=setTimeout(function(){f.onreadystatechange=M,f.abort(),l(f,"timeout"),d(f)},c)),f.send("GET"===r?null:o),f}function t(e,t,n,r){return ne(t)&&(r=n,n=t,t={}),{url:e,data:t,success:n,dataType:r}}return e.setting={type:"GET",success:M,error:M,complete:M,dataType:"json",contentType:"application/x-www-form-urlencoded",data:{},xhr:function(){return new XMLHttpRequest},timeout:0},e.get=function(){return e(t.apply(null,arguments))},e.post=function(){var n=t.apply(null,arguments);return n.type="POST",e(n)},e}(),t.type=k.type=function(){function e(e){if(null===e)return"null";if(void 0===e)return"undefined";if(ye(e))return"nan";var n=Y(e).match(t);return n?n[1].toLowerCase():""}var t=/^\[object\s+(.*?)]$/;return e}()),ft=t.stringify=k.stringify=function(){function e(e,n){return(0,a.default)(e,t(),n)}function t(){var e=[],t=[];return function(n,r){if(e.length>0){var i=e.indexOf(this);i>-1?(e.splice(i+1),t.splice(i,1/0,n)):(e.push(this),t.push(n));var o=e.indexOf(r);o>-1&&(r=e[0]===r?"[Circular ~]":"[Circular ~."+t.slice(0,o).join(".")+"]")}else e.push(r);return ke(r)||ne(r)?r="["+q(dt(r))+" "+z(r)+"]":S(r)&&(r=null),r}}return e}();t.LocalStore=k.LocalStore=function(e){var t=Xe("local");return st.extend({initialize:function(e,n){this._name=e;var r=t.getItem(e);try{r=JSON.parse(r)}catch(e){r={}}T(r)||(r={}),n=ue(r,n),this.callSuper(st,"initialize",[n])},save:function(e){if(ve(e))return t.removeItem(this._name);t.setItem(this._name,ft(e))}})}(),t.stripHtmlTag=k.stripHtmlTag=function(){function e(e){return e.replace(t,"")}var t=/<[^>]*>/g;return e}(),t.tryIt=k.tryIt=function(){function e(e,t){t=t||M;try{t(null,e())}catch(e){return void t(e)}}return e}(),t.uniqId=k.uniqId=function(){function e(e){var n=++t+"";return e?e+n:n}var t=0;return e}(),t.unique=k.unique=function(){function e(e,n){return n=n||t,Ce(e,function(e,t,r){for(var i=r.length;++t= 2.0.0-beta.1",7:">= 4.0.0"};t.REVISION_CHANGES=f;r.prototype={constructor:r,logger:d.default,log:d.default.log,registerHelper:function(e,t){if("[object Object]"===o.toString.call(e)){if(t)throw new s.default("Arg not supported with multiple helpers");o.extend(this.helpers,e)}else this.helpers[e]=t},unregisterHelper:function(e){delete this.helpers[e]},registerPartial:function(e,t){if("[object Object]"===o.toString.call(e))o.extend(this.partials,e);else{if(void 0===t)throw new s.default('Attempting to register a partial called "'+e+'" as undefined');this.partials[e]=t}},unregisterPartial:function(e){delete this.partials[e]},registerDecorator:function(e,t){if("[object Object]"===o.toString.call(e)){if(t)throw new s.default("Arg not supported with multiple decorators");o.extend(this.decorators,e)}else this.decorators[e]=t},unregisterDecorator:function(e){delete this.decorators[e]}};var p=d.default.log;t.log=p,t.createFrame=o.createFrame,t.logger=d.default},function(e,t){"use strict";function n(e){return c[e]}function r(e){for(var t=1;t":">",'"':""","'":"'","`":"`","=":"="},d=/[&<>"'`=]/g,f=/[&<>"'`=]/,p=Object.prototype.toString;t.toString=p;var h=function(e){return"function"==typeof e};h(/x/)&&(t.isFunction=h=function(e){return"function"==typeof e&&"[object Function]"===p.call(e)}),t.isFunction=h;var v=Array.isArray||function(e){return!(!e||"object"!=typeof e)&&"[object Array]"===p.call(e)};t.isArray=v},function(e,t,n){"use strict";function r(e,t){var n=t&&t.loc,a=void 0,s=void 0;n&&(a=n.start.line,s=n.start.column,e+=" - "+a+":"+s);for(var u=Error.prototype.constructor.call(this,e),l=0;l0?(n.ids&&(n.ids=[n.name]),e.helpers.each(t,n)):i(this);if(n.data&&n.ids){var a=r.createFrame(n.data);a.contextPath=r.appendContextPath(n.data.contextPath,n.name),n={data:a}}return o(t,n)})},e.exports=t.default},function(e,t,n){"use strict";var r=n(2).default;t.__esModule=!0;var i=n(4),o=n(5),a=r(o);t.default=function(e){e.registerHelper("each",function(e,t){function n(t,n,o){l&&(l.key=t,l.index=n,l.first=0===n,l.last=!!o,c&&(l.contextPath=c+t)),u+=r(e[t],{data:l,blockParams:i.blockParams([e[t],t],[c+t,null])})}if(!t)throw new a.default("Must pass iterator to #each");var r=t.fn,o=t.inverse,s=0,u="",l=void 0,c=void 0;if(t.data&&t.ids&&(c=i.appendContextPath(t.data.contextPath,t.ids[0])+"."),i.isFunction(e)&&(e=e.call(this)),t.data&&(l=i.createFrame(t.data)),e&&"object"==typeof e)if(i.isArray(e))for(var d=e.length;s=0?t:parseInt(e,10)}return e},log:function(e){if(e=i.lookupLevel(e),"undefined"!=typeof console&&i.lookupLevel(i.level)<=e){var t=i.methodMap[e];console[t]||(t="log");for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o3&&void 0!==arguments[3]?arguments[3]:["#2196f3","#707d8b","#f44336","#009688","#ffc107"],i=this._genId("settings");return this._settings.push({config:e,key:t,id:i}),this._$el.append(this._colorTpl({desc:n,colors:r,id:i,val:e.get(t)})),this}},{key:"select",value:function(e,t,n,r){var i=this._genId("settings");return this._settings.push({config:e,key:t,id:i}),this._$el.append(this._selectTpl({desc:n,selections:r,id:i,val:e.get(t)})),this}},{key:"range",value:function(e,t,n,r){var i=r.min,o=void 0===i?0:i,a=r.max,s=void 0===a?1:a,u=r.step,l=void 0===u?.1:u,c=this._genId("settings");this._settings.push({config:e,key:t,min:o,max:s,step:l,id:c});var d=e.get(t);return this._$el.append(this._rangeTpl({desc:n,min:o,max:s,step:l,val:d,progress:y(d,o,s),id:c})),this}},{key:"separator",value:function(){return this._$el.append('
'),this}},{key:"text",value:function(e){return this._$el.append('
'+e+"
"),this}},{key:"_cleanSeparator",value:function(){function e(e){return"eruda-separator"===e.getAttribute("class")}for(var t=(0,_.clone)(this._$el.get(0).children),n=0,r=t.length;n0?r:n)(e)}},function(e,t,n){var r=n(44)("keys"),i=n(31);e.exports=function(e){return r[e]||(r[e]=i(e))}},function(e,t,n){var r=n(11),i=r["__core-js_shared__"]||(r["__core-js_shared__"]={});e.exports=function(e){return i[e]||(i[e]={})}},function(e,t){e.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},function(e,t){t.f=Object.getOwnPropertySymbols},function(e,t,n){"use strict";var r=n(96)(!0);n(67)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,n=this._i;return n>=t.length?{value:void 0,done:!0}:(e=r(t,n),this._i+=e.length,{value:e,done:!1})})},function(e,t){e.exports=!0},function(e,t,n){var r=n(21),i=n(98),o=n(45),a=n(43)("IE_PROTO"),s=function(){},u=function(){var e,t=n(39)("iframe"),r=o.length;for(t.style.display="none",n(69).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write(" - - - - - - - - - - - -
- -
-
-
- -
-
-
- 拟声鸟工具箱 -
- -
-
- -
-
1. 请输入中文
- -
-
- -
2. 请直接录音,点击停止结束
- - - -
-
-
或上传音频
- - -
-
-
-
3. 选择Synthesizer模型
- - - -
-
-
4. 选择Vocoder模型
- - - -
-
- -
- - - - -
-
-
- - - - - - - - - - - - - - - \ No newline at end of file