python_code stringlengths 0 992k | repo_name stringlengths 8 46 | file_path stringlengths 5 162 |
|---|---|---|
#!/usr/bin/env python3
# Copyright 2021-2022 Xiaomi Corp. (authors: Fangjun Kuang,
# Wei Kang,
# Mingshuang Luo)
# Copyright 2023 (authors: Feiteng Li)
#
# See ../../../../... | EXA-1-master | exa/models/valle/vall-e-main/valle/bin/trainer.py |
# Copyright 2023 (authors: Feiteng Li)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... | EXA-1-master | exa/models/valle/vall-e-main/valle/tests/model_test.py |
# Copyright 2023 (authors: Zhao Ming)
# Copyright 2023 (authors: Feiteng Li)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ... | EXA-1-master | exa/models/valle/vall-e-main/valle/tests/data/tokenizer_test.py |
# Copyright 2020 Mobvoi Inc. (authors: Fangjun Kuang)
#
# See ../../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# ... | EXA-1-master | exa/models/valle/vall-e-main/valle/utils/symbol_table.py |
from .symbol_table import SymbolTable
| EXA-1-master | exa/models/valle/vall-e-main/valle/utils/__init__.py |
# Copyright 2023 (authors: Feiteng Li)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... | EXA-1-master | exa/models/valle/vall-e-main/valle/models/valle.py |
import argparse
import torch.nn as nn
from icefall.utils import AttributeDict, str2bool
from .transformer import Transformer
from .valle import NUM_MEL_BINS, VALLE, VALLF
from .visualizer import visualize
def add_model_arguments(parser: argparse.ArgumentParser):
parser.add_argument(
"--model-name",
... | EXA-1-master | exa/models/valle/vall-e-main/valle/models/__init__.py |
# Copyright 2023 (authors: Feiteng Li)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... | EXA-1-master | exa/models/valle/vall-e-main/valle/models/transformer.py |
#!/usr/bin/env python3
# Copyright 2023 (authors: Feiteng Li)
#
# See ../../../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a co... | EXA-1-master | exa/models/valle/vall-e-main/valle/models/visualizer.py |
# Copyright 2023 (authors: Feiteng Li)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by... | EXA-1-master | exa/models/valle/vall-e-main/valle/modules/embedding.py |
EXA-1-master | exa/models/valle/vall-e-main/valle/modules/__init__.py | |
from typing import Optional, Tuple
import torch
from torch import Tensor
from torch.nn import Module
from torch.nn import functional as F
from torch.nn.init import constant_, xavier_normal_, xavier_uniform_
from torch.nn.modules.linear import NonDynamicallyQuantizableLinear
from torch.nn.parameter import Parameter
c... | EXA-1-master | exa/models/valle/vall-e-main/valle/modules/activation.py |
import copy
import numbers
from typing import Any, Callable, List, Optional, Tuple, Union
import torch
from torch import Tensor, nn
from torch.nn import functional as F
from .activation import MultiheadAttention
_shape_t = Union[int, List[int], torch.Size]
class LayerNorm(nn.Module):
__constants__ = ["normaliz... | EXA-1-master | exa/models/valle/vall-e-main/valle/modules/transformer.py |
#!/usr/bin/env python3
# Copyright 2023 (authors: Feiteng Li)
#
# See ../../../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a co... | EXA-1-master | exa/models/valle/vall-e-main/valle/modules/scheduler.py |
# Copyright 2022 Xiaomi Corp. (authors: Daniel Povey)
#
# See ../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http... | EXA-1-master | exa/models/valle/vall-e-main/valle/modules/optim.py |
# Copyright 2023 (authors: Feiteng Li)
#
# See ../../../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | EXA-1-master | exa/models/valle/vall-e-main/valle/data/fbank.py |
from .datamodule import *
from .tokenizer import *
from .collation import *
| EXA-1-master | exa/models/valle/vall-e-main/valle/data/__init__.py |
from pathlib import Path
from typing import List, Tuple
import numpy as np
import torch
from valle.utils import SymbolTable
class TextTokenCollater:
"""Collate list of text tokens
Map sentences to integers. Sentences are padded to equal length.
Beginning and end-of-sequence symbols can be added.
E... | EXA-1-master | exa/models/valle/vall-e-main/valle/data/collation.py |
# Copyright 2023 (authors: Feiteng Li)
#
# See ../../../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
... | EXA-1-master | exa/models/valle/vall-e-main/valle/data/dataset.py |
#!/usr/bin/env python3
# Copyright 2023 (authors: Feiteng Li)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
... | EXA-1-master | exa/models/valle/vall-e-main/valle/data/tokenizer.py |
import random
from collections import defaultdict
from concurrent.futures import ThreadPoolExecutor
from typing import Tuple, Type
from lhotse import CutSet
from lhotse.dataset.collation import collate_features
from lhotse.dataset.input_strategies import (
ExecutorType,
PrecomputedFeatures,
_get_executor,
... | EXA-1-master | exa/models/valle/vall-e-main/valle/data/input_strategies.py |
# Copyright 2023 (authors: Feiteng Li)
#
# See ../../../../LICENSE for clarification regarding multiple authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | EXA-1-master | exa/models/valle/vall-e-main/valle/data/datamodule.py |
import subprocess
from pathlib import Path
from datetime import datetime
from setuptools import setup, find_packages
def shell(*args):
out = subprocess.check_output(args)
return out.decode("ascii").strip()
def write_version(version_core, pre_release=True):
if pre_release:
time = shell("git", "lo... | EXA-1-master | exa/models/valle/vall-e-main 2/setup.py |
#!/usr/bin/env python3
import argparse
import json
import re
from pathlib import Path
import matplotlib.pyplot as plt
import pandas as pd
def plot(paths, args):
dfs = []
for path in paths:
with open(path, "r") as f:
text = f.read()
rows = []
pattern = r"(\{.+?\})"
... | EXA-1-master | exa/models/valle/vall-e-main 2/scripts/plot.py |
from dataclasses import dataclass, field
from functools import cached_property
from pathlib import Path
import diskcache
from .utils import Config as ConfigBase
@dataclass(frozen=True)
class Config(ConfigBase):
data_root: Path = Path("data")
data_dirs: list[Path] = field(default_factory=lambda: [])
@pr... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/config.py |
EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/__init__.py | |
import argparse
import torch
from .data import VALLEDatset, create_train_val_dataloader
from .train import load_engines
def main():
parser = argparse.ArgumentParser("Save trained model to path.")
parser.add_argument("path")
args = parser.parse_args()
engine = load_engines()
model = engine["mode... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/export.py |
import json
import logging
from collections import defaultdict
import torch
from tqdm import tqdm
from .config import cfg
from .data import create_train_val_dataloader
from .emb import qnt
from .utils import setup_logging, to_device, trainer
from .vall_e import get_model
_logger = logging.getLogger(__name__)
def l... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/train.py |
"""
A sampler that balances data by key_fns.
MIT License
Copyright (c) 2023 Zhe Niu
niuzhe.nz@outlook.com
"""
import random
class Sampler:
def __init__(self, l, key_fns):
self.tree = self._build(l, key_fns)
def _build(self, l, key_fns) -> dict[dict, list]:
if not key_fns:
retu... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/sampler.py |
import argparse
from pathlib import Path
import torch
from einops import rearrange
from .emb import g2p, qnt
from .utils import to_device
def main():
parser = argparse.ArgumentParser("VALL-E TTS")
parser.add_argument("text")
parser.add_argument("reference", type=Path)
parser.add_argument("out_path",... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/__main__.py |
import copy
import logging
import random
from collections import defaultdict
from functools import cache, cached_property
from itertools import groupby, zip_longest
from typing import Any
import numpy as np
import torch
from torch import Tensor
from torch.utils.data import DataLoader, Dataset
from tqdm import tqdm
fr... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/data.py |
EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/emb/__init__.py | |
import argparse
import random
from functools import cache
from pathlib import Path
import soundfile
import torch
import torchaudio
from einops import rearrange
from encodec import EncodecModel
from encodec.utils import convert_audio
from torch import Tensor
from tqdm import tqdm
from ..config import cfg
@cache
def ... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/emb/qnt.py |
import argparse
import random
import string
from functools import cache
from pathlib import Path
import torch
from g2p_en import G2p
from tqdm import tqdm
@cache
def _get_model():
return G2p()
@cache
def _get_graphs(path):
with open(path, "r") as f:
graphs = f.read()
return graphs
def encode(... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/emb/g2p.py |
from ..config import cfg
from .ar import AR
from .nar import NAR
def get_model(name):
name = name.lower()
if name.startswith("ar"):
Model = AR
elif name.startswith("nar"):
Model = NAR
else:
raise ValueError("Model name should start with AR or NAR.")
if "-quarter" in name:... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/vall_e/__init__.py |
import torch
from torch import Tensor
from .base import Base
class NAR(Base):
@property
def n_resp_levels(self):
return 7
@property
def casual(self):
return False
@property
def use_stop_token(self):
return False
@property
def norm_type(self):
return ... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/vall_e/nar.py |
import torch
from einops import rearrange
from torch import Tensor
from tqdm import trange
from .base import Base
class AR(Base):
@property
def n_resp_levels(self):
return 1
@property
def casual(self):
return True
@property
def use_stop_token(self):
return True
... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/vall_e/ar.py |
import math
from functools import partial
from typing import Literal, overload
import torch
import torch.nn.functional as F
from einops import rearrange
from torch import Tensor, einsum, nn
from torch.distributions import Categorical
from torch.nn.utils.rnn import pad_sequence
from torch.utils.checkpoint import checkp... | EXA-1-master | exa/models/valle/vall-e-main 2/vall_e/vall_e/base.py |
import sys
import os
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
sys.path.append(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'NeuralSeq'))
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__))... | EXA-1-master | exa/models/AudioGPT/audio-chatgpt.py |
from data_gen.tts.base_preprocess import BasePreprocessor
class LJPreprocess(BasePreprocessor):
def meta_data(self):
for l in open(f'{self.raw_data_dir}/metadata.csv').readlines():
item_name, _, txt = l.strip().split("|")
wav_fn = f"{self.raw_data_dir}/wavs/{item_name}.wav"
... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/egs/datasets/audio/lj/preprocess.py |
import os
from data_gen.tts.base_preprocess import BasePreprocessor
import glob
class LibrittsPreAlign(BasePreprocessor):
def meta_data(self):
wav_fns = sorted(glob.glob(f'{self.raw_data_dir}/*/*/*.wav'))
for wav_fn in wav_fns:
item_name = os.path.basename(wav_fn)[:-4]
txt... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/egs/datasets/audio/libritts/pre_align.py |
import os
from data_gen.tts.base_pre_align import BasePreAlign
import glob
class VCTKPreAlign(BasePreAlign):
def meta_data(self):
wav_fns = glob.glob(f'{self.raw_data_dir}/wav48/*/*.wav')
for wav_fn in wav_fns:
item_name = os.path.basename(wav_fn)[:-4]
spk = item_name.spli... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/egs/datasets/audio/vctk/pre_align.py |
import os
from data_gen.tts.base_preprocess import BasePreprocessor
import glob
import re
class EmoPreAlign(BasePreprocessor):
def meta_data(self):
spks = ['0012', '0011', '0013', '0014', '0015', '0016', '0017', '0018', '0019', '0020']
pattern = re.compile('[\t\n ]+')
for spk in spks:
... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/egs/datasets/audio/emotion/pre_align.py |
import importlib
from utils.hparams import set_hparams, hparams
def run_task():
assert hparams['task_cls'] != ''
pkg = ".".join(hparams["task_cls"].split(".")[:-1])
cls_name = hparams["task_cls"].split(".")[-1]
task_cls = getattr(importlib.import_module(pkg), cls_name)
task_cls.start()
if __name... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/run.py |
import glob
import re
import subprocess
from datetime import datetime
import matplotlib
matplotlib.use('Agg')
from utils.hparams import hparams, set_hparams
import random
import sys
import numpy as np
import torch.distributed as dist
from pytorch_lightning.loggers import TensorBoardLogger
from utils.pl_utils import ... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/base_task.py |
import torch
import utils
from modules.diff.diffusion import GaussianDiffusion
from modules.diff.net import DiffNet
from tasks.tts.fs2 import FastSpeech2Task
from utils.hparams import hparams
DIFF_DECODERS = {
'wavenet': lambda hp: DiffNet(hp['audio_num_mel_bins']),
}
class DiffFsTask(FastSpeech2Task):
def... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/svs/task.py |
EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/svs/__init__.py | |
import torch
import utils
from utils.hparams import hparams
from modules.diff.net import DiffNet
from modules.diff.shallow_diffusion_tts import GaussianDiffusion
from tasks.svs.task import DiffFsTask
from vocoders.base_vocoder import get_vocoder_cls, BaseVocoder
from utils.pitch_utils import denorm_f0
from tasks.tts.f... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/svs/diffspeech_task.py |
import torch
import utils
from utils.hparams import hparams
from modules.diff.net import DiffNet
from modules.diff.shallow_diffusion_tts import GaussianDiffusion, OfflineGaussianDiffusion
from tasks.svs.diffspeech_task import DiffSpeechTask
from vocoders.base_vocoder import get_vocoder_cls, BaseVocoder
from modules.fa... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/svs/diffsinger_task.py |
import os
import torch
import torch.nn.functional as F
import torch.nn as nn
import numpy as np
from modules.portaspeech.portaspeech import PortaSpeech
from modules.syntaspeech.multi_window_disc import Discriminator
from tasks.tts.fs2 import FastSpeech2Task
from utils.hparams import hparams
from utils.tts_utils import... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/ps_adv.py |
import filecmp
import matplotlib
from utils.plot import spec_to_figure
matplotlib.use('Agg')
from data_gen.tts.data_gen_utils import get_pitch
from modules.fastspeech.tts_modules import mel2ph_to_dur
from tasks.tts.dataset_utils import BaseTTSDataset
from utils.tts_utils import sequence_mask
from multiprocessing.po... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/tts_base.py |
from multiprocessing.pool import Pool
import matplotlib
from utils.pl_utils import data_loader
from utils.training_utils import RSQRTSchedule
from vocoders.base_vocoder import get_vocoder_cls, BaseVocoder
from modules.fastspeech.pe import PitchExtractor
matplotlib.use('Agg')
import os
import numpy as np
from tqdm im... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/tts.py |
from utils.cwt import get_lf0_cwt
import torch.optim
import torch.utils.data
import importlib
from utils.indexed_datasets import IndexedDataset
from utils.pitch_utils import norm_interp_f0, denorm_f0, f0_to_coarse
import numpy as np
from tasks.base_task import BaseDataset
import torch
import torch.optim
import torch.ut... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/dataset_utils.py |
import importlib
from data_gen.tts.base_binarizer import BaseBinarizer
from data_gen.tts.base_preprocess import BasePreprocessor
from data_gen.tts.txt_processors.base_text_processor import get_txt_processor_cls
from utils.hparams import hparams
def parse_dataset_configs():
max_tokens = hparams['max_tokens']
... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/tts_utils.py |
from tasks.tts.fs2 import FastSpeech2Task
from modules.syntaspeech.multi_window_disc import Discriminator
from utils.hparams import hparams
from torch import nn
import torch
import torch.optim
import torch.utils.data
import utils
class FastSpeech2AdvTask(FastSpeech2Task):
def build_model(self):
self.build... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/fs2_adv.py |
import matplotlib
matplotlib.use('Agg')
from utils import audio
import matplotlib.pyplot as plt
from data_gen.tts.data_gen_utils import get_pitch
from tasks.tts.fs2_utils import FastSpeechDataset
from utils.cwt import cwt2f0
from utils.pl_utils import data_loader
import os
from multiprocessing.pool import Pool
from tqd... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/fs2.py |
import torch
from modules.portaspeech.portaspeech_flow import PortaSpeechFlow
from tasks.tts.fs2 import FastSpeech2Task
from tasks.tts.ps import PortaSpeechTask
from utils.pitch_utils import denorm_f0
from utils.hparams import hparams
class PortaSpeechFlowTask(PortaSpeechTask):
def __init__(self):
super()... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/ps_flow.py |
import matplotlib
matplotlib.use('Agg')
import glob
import importlib
from utils.cwt import get_lf0_cwt
import os
import torch.optim
import torch.utils.data
from utils.indexed_datasets import IndexedDataset
from utils.pitch_utils import norm_interp_f0
import numpy as np
from tasks.base_task import BaseDataset
import t... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/fs2_utils.py |
import os
import torch
import torch.nn.functional as F
from torch import nn
from modules.tts.syntaspeech.syntaspeech import SyntaSpeech
from tasks.tts.ps_adv import PortaSpeechAdvTask
from utils.hparams import hparams
class SyntaSpeechTask(PortaSpeechAdvTask):
def build_tts_model(self):
ph_dict_size = le... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/synta.py |
import os
import torch
import torch.nn.functional as F
from torch import nn
from modules.portaspeech.portaspeech import PortaSpeech
from tasks.tts.fs2 import FastSpeech2Task
from utils.tts_utils import mel2token_to_dur
from utils.hparams import hparams
from utils.tts_utils import get_focus_rate, get_phone_coverage_rat... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/ps.py |
import matplotlib
matplotlib.use('Agg')
import torch
import numpy as np
import os
from tasks.base_task import BaseDataset
from tasks.tts.fs2 import FastSpeech2Task
from modules.fastspeech.pe import PitchExtractor
import utils
from utils.indexed_datasets import IndexedDataset
from utils.hparams import hparams
from uti... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/tts/pe.py |
import glob
import importlib
import os
from resemblyzer import VoiceEncoder
import numpy as np
import torch
import torch.distributed as dist
from torch.utils.data import DistributedSampler
import utils
from tasks.base_task import BaseDataset
from utils.hparams import hparams
from utils.indexed_datasets import IndexedDa... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/vocoder/dataset_utils.py |
import os
import torch
import torch.distributed as dist
from torch.utils.data import DistributedSampler
from tasks.base_task import BaseTask
from tasks.base_task import data_loader
from tasks.vocoder.dataset_utils import VocoderDataset, EndlessDistributedSampler
from utils.hparams import hparams
class VocoderBaseTa... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/tasks/vocoder/vocoder_base.py |
import librosa
from utils.hparams import hparams
import numpy as np
def denoise(wav, v=0.1):
spec = librosa.stft(y=wav, n_fft=hparams['fft_size'], hop_length=hparams['hop_size'],
win_length=hparams['win_size'], pad_mode='constant')
spec_m = np.abs(spec)
spec_m = np.clip(spec_m - v... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/vocoders/vocoder_utils.py |
import glob
import re
import librosa
import torch
import yaml
from sklearn.preprocessing import StandardScaler
from torch import nn
from modules.parallel_wavegan.models import ParallelWaveGANGenerator
from modules.parallel_wavegan.utils import read_hdf5
from utils.hparams import hparams
from utils.pitch_utils import f0... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/vocoders/pwg.py |
from vocoders import hifigan
| EXA-1-master | exa/models/AudioGPT/NeuralSeq/vocoders/__init__.py |
import glob
import json
import os
import re
import librosa
import torch
import utils
from modules.hifigan.hifigan import HifiGanGenerator
from utils.hparams import hparams, set_hparams
from vocoders.base_vocoder import register_vocoder
from vocoders.pwg import PWG
from vocoders.vocoder_utils import denoise
def load... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/vocoders/hifigan.py |
import importlib
VOCODERS = {}
def register_vocoder(cls):
VOCODERS[cls.__name__.lower()] = cls
VOCODERS[cls.__name__] = cls
return cls
def get_vocoder_cls(hparams):
if hparams['vocoder'] in VOCODERS:
return VOCODERS[hparams['vocoder']]
else:
vocoder_cls = hparams['vocoder']
... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/vocoders/base_vocoder.py |
import warnings
warnings.filterwarnings("ignore")
import parselmouth
import os
import torch
from skimage.transform import resize
from utils.text_encoder import TokenTextEncoder
from utils.pitch_utils import f0_to_coarse
import struct
import webrtcvad
from scipy.ndimage.morphology import binary_dilation
import librosa... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/data_gen_utils.py |
import os
os.environ["OMP_NUM_THREADS"] = "1"
from utils.multiprocess_utils import chunked_multiprocess_run
import random
import traceback
import json
from resemblyzer import VoiceEncoder
from tqdm import tqdm
from data_gen.tts.data_gen_utils import get_mel2ph, get_pitch, build_phone_encoder
from utils.hparams import ... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/base_binarizer.py |
import os
os.environ["OMP_NUM_THREADS"] = "1"
import torch
from collections import Counter
from utils.text_encoder import TokenTextEncoder
from data_gen.tts.emotion import inference as EmotionEncoder
from data_gen.tts.emotion.inference import embed_utterance as Embed_utterance
from data_gen.tts.emotion.inference impor... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/base_binarizer_emotion.py |
import os
os.environ["OMP_NUM_THREADS"] = "1"
from data_gen.tts.txt_processors.zh_g2pM import ALL_SHENMU
from data_gen.tts.base_binarizer import BaseBinarizer, BinarizationError
from data_gen.tts.data_gen_utils import get_mel2ph
from utils.hparams import set_hparams, hparams
import numpy as np
class ZhBinarizer(Bas... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/binarizer_zh.py |
import json
import os
import random
import re
import traceback
from collections import Counter
from functools import partial
import pandas as pd
import librosa
from tqdm import tqdm
from data_gen.tts.txt_processors.base_text_processor import get_txt_processor_cls
from data_gen.tts.wav_processors.base_processor import g... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/base_preprocess.py |
import os
import subprocess
import librosa
import numpy as np
from data_gen.tts.wav_processors.base_processor import BaseWavProcessor, register_wav_processors
from data_gen.tts.data_gen_utils import trim_long_silences
from utils.audio import save_wav, rnnoise
from utils.hparams import hparams
@register_wav_processors... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/wav_processors/common_processors.py |
from . import base_processor
from . import common_processors
| EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/wav_processors/__init__.py |
REGISTERED_WAV_PROCESSORS = {}
def register_wav_processors(name):
def _f(cls):
REGISTERED_WAV_PROCESSORS[name] = cls
return cls
return _f
def get_wav_processor_cls(name):
return REGISTERED_WAV_PROCESSORS.get(name, None)
class BaseWavProcessor:
@property
def name(self):
... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/wav_processors/base_processor.py |
from . import en | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/txt_processors/__init__.py |
import re
import jieba
from pypinyin import pinyin, Style
from data_gen.tts.data_gen_utils import PUNCS
from data_gen.tts.txt_processors.base_text_processor import BaseTxtProcessor
from utils.text_norm import NSWNormalizer
class TxtProcessor(BaseTxtProcessor):
table = {ord(f): ord(t) for f, t in zip(
u':,... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/txt_processors/zh.py |
import re
import unicodedata
from g2p_en import G2p
from g2p_en.expand import normalize_numbers
from nltk import pos_tag
from nltk.tokenize import TweetTokenizer
from data_gen.tts.txt_processors.base_text_processor import BaseTxtProcessor, register_txt_processors
from data_gen.tts.data_gen_utils import is_sil_phoneme... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/txt_processors/en.py |
from data_gen.tts.data_gen_utils import is_sil_phoneme
REGISTERED_TEXT_PROCESSORS = {}
def register_txt_processors(name):
def _f(cls):
REGISTERED_TEXT_PROCESSORS[name] = cls
return cls
return _f
def get_txt_processor_cls(name):
return REGISTERED_TEXT_PROCESSORS.get(name, None)
class B... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/txt_processors/base_text_processor.py |
import re
import jieba
from pypinyin import pinyin, Style
from data_gen.tts.data_gen_utils import PUNCS
from data_gen.tts.txt_processors import zh
from g2pM import G2pM
ALL_SHENMU = ['zh', 'ch', 'sh', 'b', 'p', 'm', 'f', 'd', 't', 'n', 'l', 'g', 'k', 'h', 'j',
'q', 'x', 'r', 'z', 'c', 's', 'y', 'w']
ALL_... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/txt_processors/zh_g2pM.py |
## Mel-filterbank
mel_window_length = 25 # In milliseconds
mel_window_step = 10 # In milliseconds
mel_n_channels = 40
## Audio
sampling_rate = 16000
# Number of spectrogram frames in a partial utterance
partials_n_frames = 160 # 1600 ms
# Number of spectrogram frames at inference
inference_n_frames = 80 ... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/emotion/params_data.py |
## Model parameters
model_hidden_size = 256
model_embedding_size = 256
model_num_layers = 3
## Training parameters
learning_rate_init = 1e-4
speakers_per_batch = 6
utterances_per_speaker = 20
| EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/emotion/params_model.py |
from data_gen.tts.emotion.params_model import *
from data_gen.tts.emotion.params_data import *
from torch.nn.utils import clip_grad_norm_
from scipy.optimize import brentq
from torch import nn
import numpy as np
import torch
class EmotionEncoder(nn.Module):
def __init__(self, device, loss_device):
super(... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/emotion/model.py |
from data_gen.tts.emotion.params_data import *
from data_gen.tts.emotion.model import EmotionEncoder
from data_gen.tts.emotion.audio import preprocess_wav # We want to expose this function from here
from matplotlib import cm
from data_gen.tts.emotion import audio
from pathlib import Path
import matplotlib.pyplot as p... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/emotion/inference.py |
from scipy.ndimage.morphology import binary_dilation
from data_gen.tts.emotion.params_data import *
from pathlib import Path
from typing import Optional, Union
import numpy as np
import webrtcvad
import librosa
import struct
int16_max = (2 ** 15) - 1
def preprocess_wav(fpath_or_wav: Union[str, Path, np.ndarray],
... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/emotion/audio.py |
#!/usr/bin/env python3 -u
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""
Run inference for pre-processed data with a trained model.
"""
import logging
import math
import numpy, math, p... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/data_gen/tts/emotion/test_emotion.py |
import os
import subprocess
def link_file(from_file, to_file):
subprocess.check_call(
f'ln -s "`realpath --relative-to="{os.path.dirname(to_file)}" "{from_file}"`" "{to_file}"', shell=True)
def move_file(from_file, to_file):
subprocess.check_call(f'mv "{from_file}" "{to_file}"', shell=True)
def co... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/os_utils.py |
import matplotlib.pyplot as plt
import numpy as np
import torch
LINE_COLORS = ['w', 'r', 'y', 'cyan', 'm', 'b', 'lime']
def spec_to_figure(spec, vmin=None, vmax=None):
if isinstance(spec, torch.Tensor):
spec = spec.cpu().numpy()
fig = plt.figure(figsize=(12, 6))
plt.pcolor(spec.T, vmin=vmin, vmax... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/plot.py |
import argparse
import os
import yaml
global_print_hparams = True
hparams = {}
class Args:
def __init__(self, **kwargs):
for k, v in kwargs.items():
self.__setattr__(k, v)
def override_config(old_config: dict, new_config: dict):
for k, v in new_config.items():
if isinstance(v, d... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/hparams.py |
import librosa
import numpy as np
from pycwt import wavelet
from scipy.interpolate import interp1d
def load_wav(wav_file, sr):
wav, _ = librosa.load(wav_file, sr=sr, mono=True)
return wav
def convert_continuos_f0(f0):
'''CONVERT F0 TO CONTINUOUS F0
Args:
f0 (ndarray): original f0 sequence wi... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/cwt.py |
import matplotlib
from torch.nn import DataParallel
from torch.nn.parallel import DistributedDataParallel
matplotlib.use('Agg')
import glob
import itertools
import subprocess
import threading
import traceback
from pytorch_lightning.callbacks import GradientAccumulationScheduler
from pytorch_lightning.callbacks import... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/pl_utils.py |
import glob
import logging
import re
import time
from collections import defaultdict
import os
import sys
import shutil
import types
import numpy as np
import torch
import torch.nn.functional as F
import torch.distributed as dist
from torch import nn
def tensors_to_scalars(metrics):
new_metrics = {}
for k, v ... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/__init__.py |
from collections import defaultdict
import torch
import torch.nn.functional as F
def make_positions(tensor, padding_idx):
"""Replace non-padding symbols with their position numbers.
Position numbers begin at padding_idx+1. Padding symbols are ignored.
"""
# The series of casts and type-conversions he... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/tts_utils.py |
# coding=utf-8
# Authors:
# 2019.5 Zhiyang Zhou (https://github.com/Joee1995/chn_text_norm.git)
# 2019.9 Jiayu DU
#
# requirements:
# - python 3.X
# notes: python 2.X WILL fail or produce misleading results
import sys, os, argparse, codecs, string, re
# ==========================================================... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/text_norm.py |
import glob
import logging
import os
import re
import torch
def get_last_checkpoint(work_dir, steps=None):
checkpoint = None
last_ckpt_path = None
ckpt_paths = get_all_ckpts(work_dir, steps)
if len(ckpt_paths) > 0:
last_ckpt_path = ckpt_paths[0]
checkpoint = torch.load(last_ckpt_path, ... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/ckpt_utils.py |
import re
import six
from six.moves import range # pylint: disable=redefined-builtin
PAD = "<pad>"
EOS = "<EOS>"
UNK = "<UNK>"
SEG = "|"
RESERVED_TOKENS = [PAD, EOS, UNK]
NUM_RESERVED_TOKENS = len(RESERVED_TOKENS)
PAD_ID = RESERVED_TOKENS.index(PAD) # Normally 0
EOS_ID = RESERVED_TOKENS.index(EOS) # Normally 1
UNK_... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/text_encoder.py |
from utils.hparams import hparams
class RSQRTSchedule(object):
def __init__(self, optimizer):
super().__init__()
self.optimizer = optimizer
self.constant_lr = hparams['lr']
self.warmup_updates = hparams['warmup_updates']
self.hidden_size = hparams['hidden_size']
sel... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/training_utils.py |
#########
# world
##########
import librosa
import numpy as np
import torch
gamma = 0
mcepInput = 3 # 0 for dB, 3 for magnitude
alpha = 0.45
en_floor = 10 ** (-80 / 20)
FFT_SIZE = 2048
f0_bin = 256
f0_max = 1100.0
f0_min = 50.0
f0_mel_min = 1127 * np.log(1 + f0_min / 700)
f0_mel_max = 1127 * np.log(1 + f0_max / 700... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/pitch_utils.py |
import pickle
from copy import deepcopy
import numpy as np
class IndexedDataset:
def __init__(self, path, num_cache=1):
super().__init__()
self.path = path
self.data_file = None
self.data_offsets = np.load(f"{path}.idx", allow_pickle=True).item()['offsets']
self.data_file ... | EXA-1-master | exa/models/AudioGPT/NeuralSeq/utils/indexed_datasets.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.