Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/.github/dependabot.yml +17 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/.github/release-drafter.yml +44 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/__init__.py +1 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/default.yaml +5 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/model_checkpoint.yaml +17 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/model_summary.yaml +5 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/none.yaml +0 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/rich_progress_bar.yaml +4 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/data/hi-fi_en-US_female.yaml +14 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/data/ljspeech.yaml +21 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/data/vctk.yaml +14 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/eval.yaml +18 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/experiment/hifi_dataset_piper_phonemizer.yaml +14 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/experiment/ljspeech.yaml +14 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/experiment/ljspeech_min_memory.yaml +18 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/experiment/multispeaker.yaml +14 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/extras/default.yaml +8 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/hparams_search/mnist_optuna.yaml +52 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/hydra/default.yaml +19 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/local/.gitkeep +0 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/aim.yaml +28 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/comet.yaml +12 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/csv.yaml +7 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/many_loggers.yaml +9 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/mlflow.yaml +12 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/neptune.yaml +9 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/tensorboard.yaml +10 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/wandb.yaml +16 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/cfm/default.yaml +3 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/decoder/default.yaml +7 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/encoder/default.yaml +18 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/matcha.yaml +15 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/optimizer/adam.yaml +4 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/paths/default.yaml +18 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/train.yaml +51 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/cpu.yaml +5 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/ddp.yaml +9 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/ddp_sim.yaml +7 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/default.yaml +20 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/gpu.yaml +5 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/mps.yaml +5 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/VERSION +1 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/__init__.py +0 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/app.py +357 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/cli.py +418 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/data/__init__.py +0 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/data/components/__init__.py +0 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/data/text_mel_datamodule.py +231 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/hifigan/LICENSE +21 -0
- almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/hifigan/README.md +101 -0
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/.github/dependabot.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# To get started with Dependabot version updates, you'll need to specify which
|
| 2 |
+
# package ecosystems to update and where the package manifests are located.
|
| 3 |
+
# Please see the documentation for all configuration options:
|
| 4 |
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
| 5 |
+
|
| 6 |
+
version: 2
|
| 7 |
+
updates:
|
| 8 |
+
- package-ecosystem: "pip" # See documentation for possible values
|
| 9 |
+
directory: "/" # Location of package manifests
|
| 10 |
+
target-branch: "dev"
|
| 11 |
+
schedule:
|
| 12 |
+
interval: "daily"
|
| 13 |
+
ignore:
|
| 14 |
+
- dependency-name: "pytorch-lightning"
|
| 15 |
+
update-types: ["version-update:semver-patch"]
|
| 16 |
+
- dependency-name: "torchmetrics"
|
| 17 |
+
update-types: ["version-update:semver-patch"]
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/.github/release-drafter.yml
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name-template: "v$RESOLVED_VERSION"
|
| 2 |
+
tag-template: "v$RESOLVED_VERSION"
|
| 3 |
+
|
| 4 |
+
categories:
|
| 5 |
+
- title: "🚀 Features"
|
| 6 |
+
labels:
|
| 7 |
+
- "feature"
|
| 8 |
+
- "enhancement"
|
| 9 |
+
- title: "🐛 Bug Fixes"
|
| 10 |
+
labels:
|
| 11 |
+
- "fix"
|
| 12 |
+
- "bugfix"
|
| 13 |
+
- "bug"
|
| 14 |
+
- title: "🧹 Maintenance"
|
| 15 |
+
labels:
|
| 16 |
+
- "maintenance"
|
| 17 |
+
- "dependencies"
|
| 18 |
+
- "refactoring"
|
| 19 |
+
- "cosmetic"
|
| 20 |
+
- "chore"
|
| 21 |
+
- title: "📝️ Documentation"
|
| 22 |
+
labels:
|
| 23 |
+
- "documentation"
|
| 24 |
+
- "docs"
|
| 25 |
+
|
| 26 |
+
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
|
| 27 |
+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions
|
| 28 |
+
|
| 29 |
+
version-resolver:
|
| 30 |
+
major:
|
| 31 |
+
labels:
|
| 32 |
+
- "major"
|
| 33 |
+
minor:
|
| 34 |
+
labels:
|
| 35 |
+
- "minor"
|
| 36 |
+
patch:
|
| 37 |
+
labels:
|
| 38 |
+
- "patch"
|
| 39 |
+
default: patch
|
| 40 |
+
|
| 41 |
+
template: |
|
| 42 |
+
## Changes
|
| 43 |
+
|
| 44 |
+
$CHANGES
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# this file is needed here to include configs when building project as a package
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/default.yaml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- model_checkpoint.yaml
|
| 3 |
+
- model_summary.yaml
|
| 4 |
+
- rich_progress_bar.yaml
|
| 5 |
+
- _self_
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/model_checkpoint.yaml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://lightning.ai/docs/pytorch/stable/api/lightning.pytorch.callbacks.ModelCheckpoint.html
|
| 2 |
+
|
| 3 |
+
model_checkpoint:
|
| 4 |
+
_target_: lightning.pytorch.callbacks.ModelCheckpoint
|
| 5 |
+
dirpath: ${paths.output_dir}/checkpoints # directory to save the model file
|
| 6 |
+
filename: checkpoint_{epoch:03d} # checkpoint filename
|
| 7 |
+
monitor: epoch # name of the logged metric which determines when model is improving
|
| 8 |
+
verbose: False # verbosity mode
|
| 9 |
+
save_last: true # additionally always save an exact copy of the last checkpoint to a file last.ckpt
|
| 10 |
+
save_top_k: 10 # save k best models (determined by above metric)
|
| 11 |
+
mode: "max" # "max" means higher metric value is better, can be also "min"
|
| 12 |
+
auto_insert_metric_name: True # when True, the checkpoints filenames will contain the metric name
|
| 13 |
+
save_weights_only: False # if True, then only the model’s weights will be saved
|
| 14 |
+
every_n_train_steps: null # number of training steps between checkpoints
|
| 15 |
+
train_time_interval: null # checkpoints are monitored at the specified time interval
|
| 16 |
+
every_n_epochs: 100 # number of epochs between checkpoints
|
| 17 |
+
save_on_train_epoch_end: null # whether to run checkpointing at the end of the training epoch or the end of validation
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/model_summary.yaml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://lightning.ai/docs/pytorch/stable/api/lightning.pytorch.callbacks.RichModelSummary.html
|
| 2 |
+
|
| 3 |
+
model_summary:
|
| 4 |
+
_target_: lightning.pytorch.callbacks.RichModelSummary
|
| 5 |
+
max_depth: 3 # the maximum depth of layer nesting that the summary will include
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/none.yaml
ADDED
|
File without changes
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/callbacks/rich_progress_bar.yaml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://lightning.ai/docs/pytorch/latest/api/lightning.pytorch.callbacks.RichProgressBar.html
|
| 2 |
+
|
| 3 |
+
rich_progress_bar:
|
| 4 |
+
_target_: lightning.pytorch.callbacks.RichProgressBar
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/data/hi-fi_en-US_female.yaml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- ljspeech
|
| 3 |
+
- _self_
|
| 4 |
+
|
| 5 |
+
# Dataset URL: https://ast-astrec.nict.go.jp/en/release/hi-fi-captain/
|
| 6 |
+
_target_: matcha.data.text_mel_datamodule.TextMelDataModule
|
| 7 |
+
name: hi-fi_en-US_female
|
| 8 |
+
train_filelist_path: data/filelists/hi-fi-captain-en-us-female_train.txt
|
| 9 |
+
valid_filelist_path: data/filelists/hi-fi-captain-en-us-female_val.txt
|
| 10 |
+
batch_size: 32
|
| 11 |
+
cleaners: [english_cleaners_piper]
|
| 12 |
+
data_statistics: # Computed for this dataset
|
| 13 |
+
mel_mean: -6.38385
|
| 14 |
+
mel_std: 2.541796
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/data/ljspeech.yaml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_target_: matcha.data.text_mel_datamodule.TextMelDataModule
|
| 2 |
+
name: ljspeech
|
| 3 |
+
train_filelist_path: data/filelists/ljs_audio_text_train_filelist.txt
|
| 4 |
+
valid_filelist_path: data/filelists/ljs_audio_text_val_filelist.txt
|
| 5 |
+
batch_size: 32
|
| 6 |
+
num_workers: 20
|
| 7 |
+
pin_memory: True
|
| 8 |
+
cleaners: [english_cleaners2]
|
| 9 |
+
add_blank: True
|
| 10 |
+
n_spks: 1
|
| 11 |
+
n_fft: 1024
|
| 12 |
+
n_feats: 80
|
| 13 |
+
sample_rate: 22050
|
| 14 |
+
hop_length: 256
|
| 15 |
+
win_length: 1024
|
| 16 |
+
f_min: 0
|
| 17 |
+
f_max: 8000
|
| 18 |
+
data_statistics: # Computed for ljspeech dataset
|
| 19 |
+
mel_mean: -5.536622
|
| 20 |
+
mel_std: 2.116101
|
| 21 |
+
seed: ${seed}
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/data/vctk.yaml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- ljspeech
|
| 3 |
+
- _self_
|
| 4 |
+
|
| 5 |
+
_target_: matcha.data.text_mel_datamodule.TextMelDataModule
|
| 6 |
+
name: vctk
|
| 7 |
+
train_filelist_path: data/filelists/vctk_audio_sid_text_train_filelist.txt
|
| 8 |
+
valid_filelist_path: data/filelists/vctk_audio_sid_text_val_filelist.txt
|
| 9 |
+
batch_size: 32
|
| 10 |
+
add_blank: True
|
| 11 |
+
n_spks: 109
|
| 12 |
+
data_statistics: # Computed for vctk dataset
|
| 13 |
+
mel_mean: -6.630575
|
| 14 |
+
mel_std: 2.482914
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/eval.yaml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @package _global_
|
| 2 |
+
|
| 3 |
+
defaults:
|
| 4 |
+
- _self_
|
| 5 |
+
- data: mnist # choose datamodule with `test_dataloader()` for evaluation
|
| 6 |
+
- model: mnist
|
| 7 |
+
- logger: null
|
| 8 |
+
- trainer: default
|
| 9 |
+
- paths: default
|
| 10 |
+
- extras: default
|
| 11 |
+
- hydra: default
|
| 12 |
+
|
| 13 |
+
task_name: "eval"
|
| 14 |
+
|
| 15 |
+
tags: ["dev"]
|
| 16 |
+
|
| 17 |
+
# passing checkpoint path is necessary for evaluation
|
| 18 |
+
ckpt_path: ???
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/experiment/hifi_dataset_piper_phonemizer.yaml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @package _global_
|
| 2 |
+
|
| 3 |
+
# to execute this experiment run:
|
| 4 |
+
# python train.py experiment=multispeaker
|
| 5 |
+
|
| 6 |
+
defaults:
|
| 7 |
+
- override /data: hi-fi_en-US_female.yaml
|
| 8 |
+
|
| 9 |
+
# all parameters below will be merged with parameters from default configurations set above
|
| 10 |
+
# this allows you to overwrite only specified parameters
|
| 11 |
+
|
| 12 |
+
tags: ["hi-fi", "single_speaker", "piper_phonemizer", "en_US", "female"]
|
| 13 |
+
|
| 14 |
+
run_name: hi-fi_en-US_female_piper_phonemizer
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/experiment/ljspeech.yaml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @package _global_
|
| 2 |
+
|
| 3 |
+
# to execute this experiment run:
|
| 4 |
+
# python train.py experiment=multispeaker
|
| 5 |
+
|
| 6 |
+
defaults:
|
| 7 |
+
- override /data: ljspeech.yaml
|
| 8 |
+
|
| 9 |
+
# all parameters below will be merged with parameters from default configurations set above
|
| 10 |
+
# this allows you to overwrite only specified parameters
|
| 11 |
+
|
| 12 |
+
tags: ["ljspeech"]
|
| 13 |
+
|
| 14 |
+
run_name: ljspeech
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/experiment/ljspeech_min_memory.yaml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @package _global_
|
| 2 |
+
|
| 3 |
+
# to execute this experiment run:
|
| 4 |
+
# python train.py experiment=multispeaker
|
| 5 |
+
|
| 6 |
+
defaults:
|
| 7 |
+
- override /data: ljspeech.yaml
|
| 8 |
+
|
| 9 |
+
# all parameters below will be merged with parameters from default configurations set above
|
| 10 |
+
# this allows you to overwrite only specified parameters
|
| 11 |
+
|
| 12 |
+
tags: ["ljspeech"]
|
| 13 |
+
|
| 14 |
+
run_name: ljspeech_min
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
model:
|
| 18 |
+
out_size: 172
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/experiment/multispeaker.yaml
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @package _global_
|
| 2 |
+
|
| 3 |
+
# to execute this experiment run:
|
| 4 |
+
# python train.py experiment=multispeaker
|
| 5 |
+
|
| 6 |
+
defaults:
|
| 7 |
+
- override /data: vctk.yaml
|
| 8 |
+
|
| 9 |
+
# all parameters below will be merged with parameters from default configurations set above
|
| 10 |
+
# this allows you to overwrite only specified parameters
|
| 11 |
+
|
| 12 |
+
tags: ["multispeaker"]
|
| 13 |
+
|
| 14 |
+
run_name: multispeaker
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/extras/default.yaml
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# disable python warnings if they annoy you
|
| 2 |
+
ignore_warnings: False
|
| 3 |
+
|
| 4 |
+
# ask user for tags if none are provided in the config
|
| 5 |
+
enforce_tags: True
|
| 6 |
+
|
| 7 |
+
# pretty print config tree at the start of the run using Rich library
|
| 8 |
+
print_config: True
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/hparams_search/mnist_optuna.yaml
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @package _global_
|
| 2 |
+
|
| 3 |
+
# example hyperparameter optimization of some experiment with Optuna:
|
| 4 |
+
# python train.py -m hparams_search=mnist_optuna experiment=example
|
| 5 |
+
|
| 6 |
+
defaults:
|
| 7 |
+
- override /hydra/sweeper: optuna
|
| 8 |
+
|
| 9 |
+
# choose metric which will be optimized by Optuna
|
| 10 |
+
# make sure this is the correct name of some metric logged in lightning module!
|
| 11 |
+
optimized_metric: "val/acc_best"
|
| 12 |
+
|
| 13 |
+
# here we define Optuna hyperparameter search
|
| 14 |
+
# it optimizes for value returned from function with @hydra.main decorator
|
| 15 |
+
# docs: https://hydra.cc/docs/next/plugins/optuna_sweeper
|
| 16 |
+
hydra:
|
| 17 |
+
mode: "MULTIRUN" # set hydra to multirun by default if this config is attached
|
| 18 |
+
|
| 19 |
+
sweeper:
|
| 20 |
+
_target_: hydra_plugins.hydra_optuna_sweeper.optuna_sweeper.OptunaSweeper
|
| 21 |
+
|
| 22 |
+
# storage URL to persist optimization results
|
| 23 |
+
# for example, you can use SQLite if you set 'sqlite:///example.db'
|
| 24 |
+
storage: null
|
| 25 |
+
|
| 26 |
+
# name of the study to persist optimization results
|
| 27 |
+
study_name: null
|
| 28 |
+
|
| 29 |
+
# number of parallel workers
|
| 30 |
+
n_jobs: 1
|
| 31 |
+
|
| 32 |
+
# 'minimize' or 'maximize' the objective
|
| 33 |
+
direction: maximize
|
| 34 |
+
|
| 35 |
+
# total number of runs that will be executed
|
| 36 |
+
n_trials: 20
|
| 37 |
+
|
| 38 |
+
# choose Optuna hyperparameter sampler
|
| 39 |
+
# you can choose bayesian sampler (tpe), random search (without optimization), grid sampler, and others
|
| 40 |
+
# docs: https://optuna.readthedocs.io/en/stable/reference/samplers.html
|
| 41 |
+
sampler:
|
| 42 |
+
_target_: optuna.samplers.TPESampler
|
| 43 |
+
seed: 1234
|
| 44 |
+
n_startup_trials: 10 # number of random sampling runs before optimization starts
|
| 45 |
+
|
| 46 |
+
# define hyperparameter search space
|
| 47 |
+
params:
|
| 48 |
+
model.optimizer.lr: interval(0.0001, 0.1)
|
| 49 |
+
data.batch_size: choice(32, 64, 128, 256)
|
| 50 |
+
model.net.lin1_size: choice(64, 128, 256)
|
| 51 |
+
model.net.lin2_size: choice(64, 128, 256)
|
| 52 |
+
model.net.lin3_size: choice(32, 64, 128, 256)
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/hydra/default.yaml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://hydra.cc/docs/configure_hydra/intro/
|
| 2 |
+
|
| 3 |
+
# enable color logging
|
| 4 |
+
defaults:
|
| 5 |
+
- override hydra_logging: colorlog
|
| 6 |
+
- override job_logging: colorlog
|
| 7 |
+
|
| 8 |
+
# output directory, generated dynamically on each run
|
| 9 |
+
run:
|
| 10 |
+
dir: ${paths.log_dir}/${task_name}/${run_name}/runs/${now:%Y-%m-%d}_${now:%H-%M-%S}
|
| 11 |
+
sweep:
|
| 12 |
+
dir: ${paths.log_dir}/${task_name}/${run_name}/multiruns/${now:%Y-%m-%d}_${now:%H-%M-%S}
|
| 13 |
+
subdir: ${hydra.job.num}
|
| 14 |
+
|
| 15 |
+
job_logging:
|
| 16 |
+
handlers:
|
| 17 |
+
file:
|
| 18 |
+
# Incorporates fix from https://github.com/facebookresearch/hydra/pull/2242
|
| 19 |
+
filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/local/.gitkeep
ADDED
|
File without changes
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/aim.yaml
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://aimstack.io/
|
| 2 |
+
|
| 3 |
+
# example usage in lightning module:
|
| 4 |
+
# https://github.com/aimhubio/aim/blob/main/examples/pytorch_lightning_track.py
|
| 5 |
+
|
| 6 |
+
# open the Aim UI with the following command (run in the folder containing the `.aim` folder):
|
| 7 |
+
# `aim up`
|
| 8 |
+
|
| 9 |
+
aim:
|
| 10 |
+
_target_: aim.pytorch_lightning.AimLogger
|
| 11 |
+
repo: ${paths.root_dir} # .aim folder will be created here
|
| 12 |
+
# repo: "aim://ip_address:port" # can instead provide IP address pointing to Aim remote tracking server which manages the repo, see https://aimstack.readthedocs.io/en/latest/using/remote_tracking.html#
|
| 13 |
+
|
| 14 |
+
# aim allows to group runs under experiment name
|
| 15 |
+
experiment: null # any string, set to "default" if not specified
|
| 16 |
+
|
| 17 |
+
train_metric_prefix: "train/"
|
| 18 |
+
val_metric_prefix: "val/"
|
| 19 |
+
test_metric_prefix: "test/"
|
| 20 |
+
|
| 21 |
+
# sets the tracking interval in seconds for system usage metrics (CPU, GPU, memory, etc.)
|
| 22 |
+
system_tracking_interval: 10 # set to null to disable system metrics tracking
|
| 23 |
+
|
| 24 |
+
# enable/disable logging of system params such as installed packages, git info, env vars, etc.
|
| 25 |
+
log_system_params: true
|
| 26 |
+
|
| 27 |
+
# enable/disable tracking console logs (default value is true)
|
| 28 |
+
capture_terminal_logs: false # set to false to avoid infinite console log loop issue https://github.com/aimhubio/aim/issues/2550
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/comet.yaml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://www.comet.ml
|
| 2 |
+
|
| 3 |
+
comet:
|
| 4 |
+
_target_: lightning.pytorch.loggers.comet.CometLogger
|
| 5 |
+
api_key: ${oc.env:COMET_API_TOKEN} # api key is loaded from environment variable
|
| 6 |
+
save_dir: "${paths.output_dir}"
|
| 7 |
+
project_name: "lightning-hydra-template"
|
| 8 |
+
rest_api_key: null
|
| 9 |
+
# experiment_name: ""
|
| 10 |
+
experiment_key: null # set to resume experiment
|
| 11 |
+
offline: False
|
| 12 |
+
prefix: ""
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/csv.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# csv logger built in lightning
|
| 2 |
+
|
| 3 |
+
csv:
|
| 4 |
+
_target_: lightning.pytorch.loggers.csv_logs.CSVLogger
|
| 5 |
+
save_dir: "${paths.output_dir}"
|
| 6 |
+
name: "csv/"
|
| 7 |
+
prefix: ""
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/many_loggers.yaml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# train with many loggers at once
|
| 2 |
+
|
| 3 |
+
defaults:
|
| 4 |
+
# - comet
|
| 5 |
+
- csv
|
| 6 |
+
# - mlflow
|
| 7 |
+
# - neptune
|
| 8 |
+
- tensorboard
|
| 9 |
+
- wandb
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/mlflow.yaml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://mlflow.org
|
| 2 |
+
|
| 3 |
+
mlflow:
|
| 4 |
+
_target_: lightning.pytorch.loggers.mlflow.MLFlowLogger
|
| 5 |
+
# experiment_name: ""
|
| 6 |
+
# run_name: ""
|
| 7 |
+
tracking_uri: ${paths.log_dir}/mlflow/mlruns # run `mlflow ui` command inside the `logs/mlflow/` dir to open the UI
|
| 8 |
+
tags: null
|
| 9 |
+
# save_dir: "./mlruns"
|
| 10 |
+
prefix: ""
|
| 11 |
+
artifact_location: null
|
| 12 |
+
# run_id: ""
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/neptune.yaml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://neptune.ai
|
| 2 |
+
|
| 3 |
+
neptune:
|
| 4 |
+
_target_: lightning.pytorch.loggers.neptune.NeptuneLogger
|
| 5 |
+
api_key: ${oc.env:NEPTUNE_API_TOKEN} # api key is loaded from environment variable
|
| 6 |
+
project: username/lightning-hydra-template
|
| 7 |
+
# name: ""
|
| 8 |
+
log_model_checkpoints: True
|
| 9 |
+
prefix: ""
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/tensorboard.yaml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://www.tensorflow.org/tensorboard/
|
| 2 |
+
|
| 3 |
+
tensorboard:
|
| 4 |
+
_target_: lightning.pytorch.loggers.tensorboard.TensorBoardLogger
|
| 5 |
+
save_dir: "${paths.output_dir}/tensorboard/"
|
| 6 |
+
name: null
|
| 7 |
+
log_graph: False
|
| 8 |
+
default_hp_metric: True
|
| 9 |
+
prefix: ""
|
| 10 |
+
# version: ""
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/logger/wandb.yaml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# https://wandb.ai
|
| 2 |
+
|
| 3 |
+
wandb:
|
| 4 |
+
_target_: lightning.pytorch.loggers.wandb.WandbLogger
|
| 5 |
+
# name: "" # name of the run (normally generated by wandb)
|
| 6 |
+
save_dir: "${paths.output_dir}"
|
| 7 |
+
offline: False
|
| 8 |
+
id: null # pass correct id to resume experiment!
|
| 9 |
+
anonymous: null # enable anonymous logging
|
| 10 |
+
project: "lightning-hydra-template"
|
| 11 |
+
log_model: False # upload lightning ckpts
|
| 12 |
+
prefix: "" # a string to put at the beginning of metric keys
|
| 13 |
+
# entity: "" # set to name of your wandb team
|
| 14 |
+
group: ""
|
| 15 |
+
tags: []
|
| 16 |
+
job_type: ""
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/cfm/default.yaml
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CFM
|
| 2 |
+
solver: euler
|
| 3 |
+
sigma_min: 1e-4
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/decoder/default.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
channels: [256, 256]
|
| 2 |
+
dropout: 0.05
|
| 3 |
+
attention_head_dim: 64
|
| 4 |
+
n_blocks: 1
|
| 5 |
+
num_mid_blocks: 2
|
| 6 |
+
num_heads: 2
|
| 7 |
+
act_fn: snakebeta
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/encoder/default.yaml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
encoder_type: RoPE Encoder
|
| 2 |
+
encoder_params:
|
| 3 |
+
n_feats: ${model.n_feats}
|
| 4 |
+
n_channels: 192
|
| 5 |
+
filter_channels: 768
|
| 6 |
+
filter_channels_dp: 256
|
| 7 |
+
n_heads: 2
|
| 8 |
+
n_layers: 6
|
| 9 |
+
kernel_size: 3
|
| 10 |
+
p_dropout: 0.1
|
| 11 |
+
spk_emb_dim: 64
|
| 12 |
+
n_spks: 1
|
| 13 |
+
prenet: true
|
| 14 |
+
|
| 15 |
+
duration_predictor_params:
|
| 16 |
+
filter_channels_dp: ${model.encoder.encoder_params.filter_channels_dp}
|
| 17 |
+
kernel_size: 3
|
| 18 |
+
p_dropout: ${model.encoder.encoder_params.p_dropout}
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/matcha.yaml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- _self_
|
| 3 |
+
- encoder: default.yaml
|
| 4 |
+
- decoder: default.yaml
|
| 5 |
+
- cfm: default.yaml
|
| 6 |
+
- optimizer: adam.yaml
|
| 7 |
+
|
| 8 |
+
_target_: matcha.models.matcha_tts.MatchaTTS
|
| 9 |
+
n_vocab: 178
|
| 10 |
+
n_spks: ${data.n_spks}
|
| 11 |
+
spk_emb_dim: 64
|
| 12 |
+
n_feats: 80
|
| 13 |
+
data_statistics: ${data.data_statistics}
|
| 14 |
+
out_size: null # Must be divisible by 4
|
| 15 |
+
prior_loss: true
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/model/optimizer/adam.yaml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_target_: torch.optim.Adam
|
| 2 |
+
_partial_: true
|
| 3 |
+
lr: 1e-4
|
| 4 |
+
weight_decay: 0.0
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/paths/default.yaml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# path to root directory
|
| 2 |
+
# this requires PROJECT_ROOT environment variable to exist
|
| 3 |
+
# you can replace it with "." if you want the root to be the current working directory
|
| 4 |
+
root_dir: ${oc.env:PROJECT_ROOT}
|
| 5 |
+
|
| 6 |
+
# path to data directory
|
| 7 |
+
data_dir: ${paths.root_dir}/data/
|
| 8 |
+
|
| 9 |
+
# path to logging directory
|
| 10 |
+
log_dir: ${paths.root_dir}/logs/
|
| 11 |
+
|
| 12 |
+
# path to output directory, created dynamically by hydra
|
| 13 |
+
# path generation pattern is specified in `configs/hydra/default.yaml`
|
| 14 |
+
# use it to store all files generated during the run, like ckpts and metrics
|
| 15 |
+
output_dir: ${hydra:runtime.output_dir}
|
| 16 |
+
|
| 17 |
+
# path to working directory
|
| 18 |
+
work_dir: ${hydra:runtime.cwd}
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/train.yaml
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# @package _global_
|
| 2 |
+
|
| 3 |
+
# specify here default configuration
|
| 4 |
+
# order of defaults determines the order in which configs override each other
|
| 5 |
+
defaults:
|
| 6 |
+
- _self_
|
| 7 |
+
- data: ljspeech
|
| 8 |
+
- model: matcha
|
| 9 |
+
- callbacks: default
|
| 10 |
+
- logger: tensorboard # set logger here or use command line (e.g. `python train.py logger=tensorboard`)
|
| 11 |
+
- trainer: default
|
| 12 |
+
- paths: default
|
| 13 |
+
- extras: default
|
| 14 |
+
- hydra: default
|
| 15 |
+
|
| 16 |
+
# experiment configs allow for version control of specific hyperparameters
|
| 17 |
+
# e.g. best hyperparameters for given model and datamodule
|
| 18 |
+
- experiment: null
|
| 19 |
+
|
| 20 |
+
# config for hyperparameter optimization
|
| 21 |
+
- hparams_search: null
|
| 22 |
+
|
| 23 |
+
# optional local config for machine/user specific settings
|
| 24 |
+
# it's optional since it doesn't need to exist and is excluded from version control
|
| 25 |
+
- optional local: default
|
| 26 |
+
|
| 27 |
+
# debugging config (enable through command line, e.g. `python train.py debug=default)
|
| 28 |
+
- debug: null
|
| 29 |
+
|
| 30 |
+
# task name, determines output directory path
|
| 31 |
+
task_name: "train"
|
| 32 |
+
|
| 33 |
+
run_name: ???
|
| 34 |
+
|
| 35 |
+
# tags to help you identify your experiments
|
| 36 |
+
# you can overwrite this in experiment configs
|
| 37 |
+
# overwrite from command line with `python train.py tags="[first_tag, second_tag]"`
|
| 38 |
+
tags: ["dev"]
|
| 39 |
+
|
| 40 |
+
# set False to skip model training
|
| 41 |
+
train: True
|
| 42 |
+
|
| 43 |
+
# evaluate on test set, using best model weights achieved during training
|
| 44 |
+
# lightning chooses best weights based on the metric specified in checkpoint callback
|
| 45 |
+
test: True
|
| 46 |
+
|
| 47 |
+
# simply provide checkpoint path to resume training
|
| 48 |
+
ckpt_path: null
|
| 49 |
+
|
| 50 |
+
# seed for random number generators in pytorch, numpy and python.random
|
| 51 |
+
seed: 1234
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/cpu.yaml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- default
|
| 3 |
+
|
| 4 |
+
accelerator: cpu
|
| 5 |
+
devices: 1
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/ddp.yaml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- default
|
| 3 |
+
|
| 4 |
+
strategy: ddp
|
| 5 |
+
|
| 6 |
+
accelerator: gpu
|
| 7 |
+
devices: [0,1]
|
| 8 |
+
num_nodes: 1
|
| 9 |
+
sync_batchnorm: True
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/ddp_sim.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- default
|
| 3 |
+
|
| 4 |
+
# simulate DDP on CPU, useful for debugging
|
| 5 |
+
accelerator: cpu
|
| 6 |
+
devices: 2
|
| 7 |
+
strategy: ddp_spawn
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/default.yaml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_target_: lightning.pytorch.trainer.Trainer
|
| 2 |
+
|
| 3 |
+
default_root_dir: ${paths.output_dir}
|
| 4 |
+
|
| 5 |
+
max_epochs: -1
|
| 6 |
+
|
| 7 |
+
accelerator: gpu
|
| 8 |
+
devices: [0]
|
| 9 |
+
|
| 10 |
+
# mixed precision for extra speed-up
|
| 11 |
+
precision: 16-mixed
|
| 12 |
+
|
| 13 |
+
# perform a validation loop every N training epochs
|
| 14 |
+
check_val_every_n_epoch: 1
|
| 15 |
+
|
| 16 |
+
# set True to to ensure deterministic results
|
| 17 |
+
# makes training slower but gives more reproducibility than just setting seeds
|
| 18 |
+
deterministic: False
|
| 19 |
+
|
| 20 |
+
gradient_clip_val: 5.0
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/gpu.yaml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- default
|
| 3 |
+
|
| 4 |
+
accelerator: gpu
|
| 5 |
+
devices: 1
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/configs/trainer/mps.yaml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
defaults:
|
| 2 |
+
- default
|
| 3 |
+
|
| 4 |
+
accelerator: mps
|
| 5 |
+
devices: 1
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
0.0.5.1
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/__init__.py
ADDED
|
File without changes
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/app.py
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import tempfile
|
| 2 |
+
from argparse import Namespace
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
import gradio as gr
|
| 6 |
+
import soundfile as sf
|
| 7 |
+
import torch
|
| 8 |
+
|
| 9 |
+
from matcha.cli import (
|
| 10 |
+
MATCHA_URLS,
|
| 11 |
+
VOCODER_URLS,
|
| 12 |
+
assert_model_downloaded,
|
| 13 |
+
get_device,
|
| 14 |
+
load_matcha,
|
| 15 |
+
load_vocoder,
|
| 16 |
+
process_text,
|
| 17 |
+
to_waveform,
|
| 18 |
+
)
|
| 19 |
+
from matcha.utils.utils import get_user_data_dir, plot_tensor
|
| 20 |
+
|
| 21 |
+
LOCATION = Path(get_user_data_dir())
|
| 22 |
+
|
| 23 |
+
args = Namespace(
|
| 24 |
+
cpu=False,
|
| 25 |
+
model="matcha_vctk",
|
| 26 |
+
vocoder="hifigan_univ_v1",
|
| 27 |
+
spk=0,
|
| 28 |
+
)
|
| 29 |
+
|
| 30 |
+
CURRENTLY_LOADED_MODEL = args.model
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def MATCHA_TTS_LOC(x):
|
| 34 |
+
return LOCATION / f"{x}.ckpt"
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def VOCODER_LOC(x):
|
| 38 |
+
return LOCATION / f"{x}"
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
LOGO_URL = "https://shivammehta25.github.io/Matcha-TTS/images/logo.png"
|
| 42 |
+
RADIO_OPTIONS = {
|
| 43 |
+
"Multi Speaker (VCTK)": {
|
| 44 |
+
"model": "matcha_vctk",
|
| 45 |
+
"vocoder": "hifigan_univ_v1",
|
| 46 |
+
},
|
| 47 |
+
"Single Speaker (LJ Speech)": {
|
| 48 |
+
"model": "matcha_ljspeech",
|
| 49 |
+
"vocoder": "hifigan_T2_v1",
|
| 50 |
+
},
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
# Ensure all the required models are downloaded
|
| 54 |
+
assert_model_downloaded(MATCHA_TTS_LOC("matcha_ljspeech"), MATCHA_URLS["matcha_ljspeech"])
|
| 55 |
+
assert_model_downloaded(VOCODER_LOC("hifigan_T2_v1"), VOCODER_URLS["hifigan_T2_v1"])
|
| 56 |
+
assert_model_downloaded(MATCHA_TTS_LOC("matcha_vctk"), MATCHA_URLS["matcha_vctk"])
|
| 57 |
+
assert_model_downloaded(VOCODER_LOC("hifigan_univ_v1"), VOCODER_URLS["hifigan_univ_v1"])
|
| 58 |
+
|
| 59 |
+
device = get_device(args)
|
| 60 |
+
|
| 61 |
+
# Load default model
|
| 62 |
+
model = load_matcha(args.model, MATCHA_TTS_LOC(args.model), device)
|
| 63 |
+
vocoder, denoiser = load_vocoder(args.vocoder, VOCODER_LOC(args.vocoder), device)
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def load_model(model_name, vocoder_name):
|
| 67 |
+
model = load_matcha(model_name, MATCHA_TTS_LOC(model_name), device)
|
| 68 |
+
vocoder, denoiser = load_vocoder(vocoder_name, VOCODER_LOC(vocoder_name), device)
|
| 69 |
+
return model, vocoder, denoiser
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def load_model_ui(model_type, textbox):
|
| 73 |
+
model_name, vocoder_name = RADIO_OPTIONS[model_type]["model"], RADIO_OPTIONS[model_type]["vocoder"]
|
| 74 |
+
|
| 75 |
+
global model, vocoder, denoiser, CURRENTLY_LOADED_MODEL # pylint: disable=global-statement
|
| 76 |
+
if CURRENTLY_LOADED_MODEL != model_name:
|
| 77 |
+
model, vocoder, denoiser = load_model(model_name, vocoder_name)
|
| 78 |
+
CURRENTLY_LOADED_MODEL = model_name
|
| 79 |
+
|
| 80 |
+
if model_name == "matcha_ljspeech":
|
| 81 |
+
spk_slider = gr.update(visible=False, value=-1)
|
| 82 |
+
single_speaker_examples = gr.update(visible=True)
|
| 83 |
+
multi_speaker_examples = gr.update(visible=False)
|
| 84 |
+
length_scale = gr.update(value=0.95)
|
| 85 |
+
else:
|
| 86 |
+
spk_slider = gr.update(visible=True, value=0)
|
| 87 |
+
single_speaker_examples = gr.update(visible=False)
|
| 88 |
+
multi_speaker_examples = gr.update(visible=True)
|
| 89 |
+
length_scale = gr.update(value=0.85)
|
| 90 |
+
|
| 91 |
+
return (
|
| 92 |
+
textbox,
|
| 93 |
+
gr.update(interactive=True),
|
| 94 |
+
spk_slider,
|
| 95 |
+
single_speaker_examples,
|
| 96 |
+
multi_speaker_examples,
|
| 97 |
+
length_scale,
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
|
| 101 |
+
@torch.inference_mode()
|
| 102 |
+
def process_text_gradio(text):
|
| 103 |
+
output = process_text(1, text, device)
|
| 104 |
+
return output["x_phones"][1::2], output["x"], output["x_lengths"]
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
@torch.inference_mode()
|
| 108 |
+
def synthesise_mel(text, text_length, n_timesteps, temperature, length_scale, spk):
|
| 109 |
+
spk = torch.tensor([spk], device=device, dtype=torch.long) if spk >= 0 else None
|
| 110 |
+
output = model.synthesise(
|
| 111 |
+
text,
|
| 112 |
+
text_length,
|
| 113 |
+
n_timesteps=n_timesteps,
|
| 114 |
+
temperature=temperature,
|
| 115 |
+
spks=spk,
|
| 116 |
+
length_scale=length_scale,
|
| 117 |
+
)
|
| 118 |
+
output["waveform"] = to_waveform(output["mel"], vocoder, denoiser)
|
| 119 |
+
with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as fp:
|
| 120 |
+
sf.write(fp.name, output["waveform"], 22050, "PCM_24")
|
| 121 |
+
|
| 122 |
+
return fp.name, plot_tensor(output["mel"].squeeze().cpu().numpy())
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def multispeaker_example_cacher(text, n_timesteps, mel_temp, length_scale, spk):
|
| 126 |
+
global CURRENTLY_LOADED_MODEL # pylint: disable=global-statement
|
| 127 |
+
if CURRENTLY_LOADED_MODEL != "matcha_vctk":
|
| 128 |
+
global model, vocoder, denoiser # pylint: disable=global-statement
|
| 129 |
+
model, vocoder, denoiser = load_model("matcha_vctk", "hifigan_univ_v1")
|
| 130 |
+
CURRENTLY_LOADED_MODEL = "matcha_vctk"
|
| 131 |
+
|
| 132 |
+
phones, text, text_lengths = process_text_gradio(text)
|
| 133 |
+
audio, mel_spectrogram = synthesise_mel(text, text_lengths, n_timesteps, mel_temp, length_scale, spk)
|
| 134 |
+
return phones, audio, mel_spectrogram
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def ljspeech_example_cacher(text, n_timesteps, mel_temp, length_scale, spk=-1):
|
| 138 |
+
global CURRENTLY_LOADED_MODEL # pylint: disable=global-statement
|
| 139 |
+
if CURRENTLY_LOADED_MODEL != "matcha_ljspeech":
|
| 140 |
+
global model, vocoder, denoiser # pylint: disable=global-statement
|
| 141 |
+
model, vocoder, denoiser = load_model("matcha_ljspeech", "hifigan_T2_v1")
|
| 142 |
+
CURRENTLY_LOADED_MODEL = "matcha_ljspeech"
|
| 143 |
+
|
| 144 |
+
phones, text, text_lengths = process_text_gradio(text)
|
| 145 |
+
audio, mel_spectrogram = synthesise_mel(text, text_lengths, n_timesteps, mel_temp, length_scale, spk)
|
| 146 |
+
return phones, audio, mel_spectrogram
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def main():
|
| 150 |
+
description = """# 🍵 Matcha-TTS: A fast TTS architecture with conditional flow matching
|
| 151 |
+
### [Shivam Mehta](https://www.kth.se/profile/smehta), [Ruibo Tu](https://www.kth.se/profile/ruibo), [Jonas Beskow](https://www.kth.se/profile/beskow), [Éva Székely](https://www.kth.se/profile/szekely), and [Gustav Eje Henter](https://people.kth.se/~ghe/)
|
| 152 |
+
We propose 🍵 Matcha-TTS, a new approach to non-autoregressive neural TTS, that uses conditional flow matching (similar to rectified flows) to speed up ODE-based speech synthesis. Our method:
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
* Is probabilistic
|
| 156 |
+
* Has compact memory footprint
|
| 157 |
+
* Sounds highly natural
|
| 158 |
+
* Is very fast to synthesise from
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
Check out our [demo page](https://shivammehta25.github.io/Matcha-TTS). Read our [arXiv preprint for more details](https://arxiv.org/abs/2309.03199).
|
| 162 |
+
Code is available in our [GitHub repository](https://github.com/shivammehta25/Matcha-TTS), along with pre-trained models.
|
| 163 |
+
|
| 164 |
+
Cached examples are available at the bottom of the page.
|
| 165 |
+
"""
|
| 166 |
+
|
| 167 |
+
with gr.Blocks(title="🍵 Matcha-TTS: A fast TTS architecture with conditional flow matching") as demo:
|
| 168 |
+
processed_text = gr.State(value=None)
|
| 169 |
+
processed_text_len = gr.State(value=None)
|
| 170 |
+
|
| 171 |
+
with gr.Box():
|
| 172 |
+
with gr.Row():
|
| 173 |
+
gr.Markdown(description, scale=3)
|
| 174 |
+
with gr.Column():
|
| 175 |
+
gr.Image(LOGO_URL, label="Matcha-TTS logo", height=50, width=50, scale=1, show_label=False)
|
| 176 |
+
html = '<br><iframe width="560" height="315" src="https://www.youtube.com/embed/xmvJkz3bqw0?si=jN7ILyDsbPwJCGoa" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'
|
| 177 |
+
gr.HTML(html)
|
| 178 |
+
|
| 179 |
+
with gr.Box():
|
| 180 |
+
radio_options = list(RADIO_OPTIONS.keys())
|
| 181 |
+
model_type = gr.Radio(
|
| 182 |
+
radio_options, value=radio_options[0], label="Choose a Model", interactive=True, container=False
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
with gr.Row():
|
| 186 |
+
gr.Markdown("# Text Input")
|
| 187 |
+
with gr.Row():
|
| 188 |
+
text = gr.Textbox(value="", lines=2, label="Text to synthesise", scale=3)
|
| 189 |
+
spk_slider = gr.Slider(
|
| 190 |
+
minimum=0, maximum=107, step=1, value=args.spk, label="Speaker ID", interactive=True, scale=1
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
with gr.Row():
|
| 194 |
+
gr.Markdown("### Hyper parameters")
|
| 195 |
+
with gr.Row():
|
| 196 |
+
n_timesteps = gr.Slider(
|
| 197 |
+
label="Number of ODE steps",
|
| 198 |
+
minimum=1,
|
| 199 |
+
maximum=100,
|
| 200 |
+
step=1,
|
| 201 |
+
value=10,
|
| 202 |
+
interactive=True,
|
| 203 |
+
)
|
| 204 |
+
length_scale = gr.Slider(
|
| 205 |
+
label="Length scale (Speaking rate)",
|
| 206 |
+
minimum=0.5,
|
| 207 |
+
maximum=1.5,
|
| 208 |
+
step=0.05,
|
| 209 |
+
value=1.0,
|
| 210 |
+
interactive=True,
|
| 211 |
+
)
|
| 212 |
+
mel_temp = gr.Slider(
|
| 213 |
+
label="Sampling temperature",
|
| 214 |
+
minimum=0.00,
|
| 215 |
+
maximum=2.001,
|
| 216 |
+
step=0.16675,
|
| 217 |
+
value=0.667,
|
| 218 |
+
interactive=True,
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
synth_btn = gr.Button("Synthesise")
|
| 222 |
+
|
| 223 |
+
with gr.Box():
|
| 224 |
+
with gr.Row():
|
| 225 |
+
gr.Markdown("### Phonetised text")
|
| 226 |
+
phonetised_text = gr.Textbox(interactive=False, scale=10, label="Phonetised text")
|
| 227 |
+
|
| 228 |
+
with gr.Box():
|
| 229 |
+
with gr.Row():
|
| 230 |
+
mel_spectrogram = gr.Image(interactive=False, label="mel spectrogram")
|
| 231 |
+
|
| 232 |
+
# with gr.Row():
|
| 233 |
+
audio = gr.Audio(interactive=False, label="Audio")
|
| 234 |
+
|
| 235 |
+
with gr.Row(visible=False) as example_row_lj_speech:
|
| 236 |
+
examples = gr.Examples( # pylint: disable=unused-variable
|
| 237 |
+
examples=[
|
| 238 |
+
[
|
| 239 |
+
"We propose Matcha-TTS, a new approach to non-autoregressive neural TTS, that uses conditional flow matching (similar to rectified flows) to speed up O D E-based speech synthesis.",
|
| 240 |
+
50,
|
| 241 |
+
0.677,
|
| 242 |
+
0.95,
|
| 243 |
+
],
|
| 244 |
+
[
|
| 245 |
+
"The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.",
|
| 246 |
+
2,
|
| 247 |
+
0.677,
|
| 248 |
+
0.95,
|
| 249 |
+
],
|
| 250 |
+
[
|
| 251 |
+
"The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.",
|
| 252 |
+
4,
|
| 253 |
+
0.677,
|
| 254 |
+
0.95,
|
| 255 |
+
],
|
| 256 |
+
[
|
| 257 |
+
"The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.",
|
| 258 |
+
10,
|
| 259 |
+
0.677,
|
| 260 |
+
0.95,
|
| 261 |
+
],
|
| 262 |
+
[
|
| 263 |
+
"The Secret Service believed that it was very doubtful that any President would ride regularly in a vehicle with a fixed top, even though transparent.",
|
| 264 |
+
50,
|
| 265 |
+
0.677,
|
| 266 |
+
0.95,
|
| 267 |
+
],
|
| 268 |
+
[
|
| 269 |
+
"The narrative of these events is based largely on the recollections of the participants.",
|
| 270 |
+
10,
|
| 271 |
+
0.677,
|
| 272 |
+
0.95,
|
| 273 |
+
],
|
| 274 |
+
[
|
| 275 |
+
"The jury did not believe him, and the verdict was for the defendants.",
|
| 276 |
+
10,
|
| 277 |
+
0.677,
|
| 278 |
+
0.95,
|
| 279 |
+
],
|
| 280 |
+
],
|
| 281 |
+
fn=ljspeech_example_cacher,
|
| 282 |
+
inputs=[text, n_timesteps, mel_temp, length_scale],
|
| 283 |
+
outputs=[phonetised_text, audio, mel_spectrogram],
|
| 284 |
+
cache_examples=True,
|
| 285 |
+
)
|
| 286 |
+
|
| 287 |
+
with gr.Row() as example_row_multispeaker:
|
| 288 |
+
multi_speaker_examples = gr.Examples( # pylint: disable=unused-variable
|
| 289 |
+
examples=[
|
| 290 |
+
[
|
| 291 |
+
"Hello everyone! I am speaker 0 and I am here to tell you that Matcha-TTS is amazing!",
|
| 292 |
+
10,
|
| 293 |
+
0.677,
|
| 294 |
+
0.85,
|
| 295 |
+
0,
|
| 296 |
+
],
|
| 297 |
+
[
|
| 298 |
+
"Hello everyone! I am speaker 16 and I am here to tell you that Matcha-TTS is amazing!",
|
| 299 |
+
10,
|
| 300 |
+
0.677,
|
| 301 |
+
0.85,
|
| 302 |
+
16,
|
| 303 |
+
],
|
| 304 |
+
[
|
| 305 |
+
"Hello everyone! I am speaker 44 and I am here to tell you that Matcha-TTS is amazing!",
|
| 306 |
+
50,
|
| 307 |
+
0.677,
|
| 308 |
+
0.85,
|
| 309 |
+
44,
|
| 310 |
+
],
|
| 311 |
+
[
|
| 312 |
+
"Hello everyone! I am speaker 45 and I am here to tell you that Matcha-TTS is amazing!",
|
| 313 |
+
50,
|
| 314 |
+
0.677,
|
| 315 |
+
0.85,
|
| 316 |
+
45,
|
| 317 |
+
],
|
| 318 |
+
[
|
| 319 |
+
"Hello everyone! I am speaker 58 and I am here to tell you that Matcha-TTS is amazing!",
|
| 320 |
+
4,
|
| 321 |
+
0.677,
|
| 322 |
+
0.85,
|
| 323 |
+
58,
|
| 324 |
+
],
|
| 325 |
+
],
|
| 326 |
+
fn=multispeaker_example_cacher,
|
| 327 |
+
inputs=[text, n_timesteps, mel_temp, length_scale, spk_slider],
|
| 328 |
+
outputs=[phonetised_text, audio, mel_spectrogram],
|
| 329 |
+
cache_examples=True,
|
| 330 |
+
label="Multi Speaker Examples",
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
model_type.change(lambda x: gr.update(interactive=False), inputs=[synth_btn], outputs=[synth_btn]).then(
|
| 334 |
+
load_model_ui,
|
| 335 |
+
inputs=[model_type, text],
|
| 336 |
+
outputs=[text, synth_btn, spk_slider, example_row_lj_speech, example_row_multispeaker, length_scale],
|
| 337 |
+
)
|
| 338 |
+
|
| 339 |
+
synth_btn.click(
|
| 340 |
+
fn=process_text_gradio,
|
| 341 |
+
inputs=[
|
| 342 |
+
text,
|
| 343 |
+
],
|
| 344 |
+
outputs=[phonetised_text, processed_text, processed_text_len],
|
| 345 |
+
api_name="matcha_tts",
|
| 346 |
+
queue=True,
|
| 347 |
+
).then(
|
| 348 |
+
fn=synthesise_mel,
|
| 349 |
+
inputs=[processed_text, processed_text_len, n_timesteps, mel_temp, length_scale, spk_slider],
|
| 350 |
+
outputs=[audio, mel_spectrogram],
|
| 351 |
+
)
|
| 352 |
+
|
| 353 |
+
demo.queue().launch(share=True)
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
if __name__ == "__main__":
|
| 357 |
+
main()
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/cli.py
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import argparse
|
| 2 |
+
import datetime as dt
|
| 3 |
+
import os
|
| 4 |
+
import warnings
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
import matplotlib.pyplot as plt
|
| 8 |
+
import numpy as np
|
| 9 |
+
import soundfile as sf
|
| 10 |
+
import torch
|
| 11 |
+
|
| 12 |
+
from matcha.hifigan.config import v1
|
| 13 |
+
from matcha.hifigan.denoiser import Denoiser
|
| 14 |
+
from matcha.hifigan.env import AttrDict
|
| 15 |
+
from matcha.hifigan.models import Generator as HiFiGAN
|
| 16 |
+
from matcha.models.matcha_tts import MatchaTTS
|
| 17 |
+
from matcha.text import sequence_to_text, text_to_sequence
|
| 18 |
+
from matcha.utils.utils import assert_model_downloaded, get_user_data_dir, intersperse
|
| 19 |
+
|
| 20 |
+
MATCHA_URLS = {
|
| 21 |
+
"matcha_ljspeech": "https://github.com/shivammehta25/Matcha-TTS-checkpoints/releases/download/v1.0/matcha_ljspeech.ckpt",
|
| 22 |
+
"matcha_vctk": "https://github.com/shivammehta25/Matcha-TTS-checkpoints/releases/download/v1.0/matcha_vctk.ckpt",
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
VOCODER_URLS = {
|
| 26 |
+
"hifigan_T2_v1": "https://github.com/shivammehta25/Matcha-TTS-checkpoints/releases/download/v1.0/generator_v1", # Old url: https://drive.google.com/file/d/14NENd4equCBLyyCSke114Mv6YR_j_uFs/view?usp=drive_link
|
| 27 |
+
"hifigan_univ_v1": "https://github.com/shivammehta25/Matcha-TTS-checkpoints/releases/download/v1.0/g_02500000", # Old url: https://drive.google.com/file/d/1qpgI41wNXFcH-iKq1Y42JlBC9j0je8PW/view?usp=drive_link
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
MULTISPEAKER_MODEL = {
|
| 31 |
+
"matcha_vctk": {"vocoder": "hifigan_univ_v1", "speaking_rate": 0.85, "spk": 0, "spk_range": (0, 107)}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
SINGLESPEAKER_MODEL = {"matcha_ljspeech": {"vocoder": "hifigan_T2_v1", "speaking_rate": 0.95, "spk": None}}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def plot_spectrogram_to_numpy(spectrogram, filename):
|
| 38 |
+
fig, ax = plt.subplots(figsize=(12, 3))
|
| 39 |
+
im = ax.imshow(spectrogram, aspect="auto", origin="lower", interpolation="none")
|
| 40 |
+
plt.colorbar(im, ax=ax)
|
| 41 |
+
plt.xlabel("Frames")
|
| 42 |
+
plt.ylabel("Channels")
|
| 43 |
+
plt.title("Synthesised Mel-Spectrogram")
|
| 44 |
+
fig.canvas.draw()
|
| 45 |
+
plt.savefig(filename)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def process_text(i: int, text: str, device: torch.device):
|
| 49 |
+
print(f"[{i}] - Input text: {text}")
|
| 50 |
+
x = torch.tensor(
|
| 51 |
+
intersperse(text_to_sequence(text, ["english_cleaners2"]), 0),
|
| 52 |
+
dtype=torch.long,
|
| 53 |
+
device=device,
|
| 54 |
+
)[None]
|
| 55 |
+
x_lengths = torch.tensor([x.shape[-1]], dtype=torch.long, device=device)
|
| 56 |
+
x_phones = sequence_to_text(x.squeeze(0).tolist())
|
| 57 |
+
print(f"[{i}] - Phonetised text: {x_phones[1::2]}")
|
| 58 |
+
|
| 59 |
+
return {"x_orig": text, "x": x, "x_lengths": x_lengths, "x_phones": x_phones}
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def get_texts(args):
|
| 63 |
+
if args.text:
|
| 64 |
+
texts = [args.text]
|
| 65 |
+
else:
|
| 66 |
+
with open(args.file, encoding="utf-8") as f:
|
| 67 |
+
texts = f.readlines()
|
| 68 |
+
return texts
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def assert_required_models_available(args):
|
| 72 |
+
save_dir = get_user_data_dir()
|
| 73 |
+
if not hasattr(args, "checkpoint_path") and args.checkpoint_path is None:
|
| 74 |
+
model_path = args.checkpoint_path
|
| 75 |
+
else:
|
| 76 |
+
model_path = save_dir / f"{args.model}.ckpt"
|
| 77 |
+
assert_model_downloaded(model_path, MATCHA_URLS[args.model])
|
| 78 |
+
|
| 79 |
+
vocoder_path = save_dir / f"{args.vocoder}"
|
| 80 |
+
assert_model_downloaded(vocoder_path, VOCODER_URLS[args.vocoder])
|
| 81 |
+
return {"matcha": model_path, "vocoder": vocoder_path}
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def load_hifigan(checkpoint_path, device):
|
| 85 |
+
h = AttrDict(v1)
|
| 86 |
+
hifigan = HiFiGAN(h).to(device)
|
| 87 |
+
hifigan.load_state_dict(torch.load(checkpoint_path, map_location=device)["generator"])
|
| 88 |
+
_ = hifigan.eval()
|
| 89 |
+
hifigan.remove_weight_norm()
|
| 90 |
+
return hifigan
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def load_vocoder(vocoder_name, checkpoint_path, device):
|
| 94 |
+
print(f"[!] Loading {vocoder_name}!")
|
| 95 |
+
vocoder = None
|
| 96 |
+
if vocoder_name in ("hifigan_T2_v1", "hifigan_univ_v1"):
|
| 97 |
+
vocoder = load_hifigan(checkpoint_path, device)
|
| 98 |
+
else:
|
| 99 |
+
raise NotImplementedError(
|
| 100 |
+
f"Vocoder {vocoder_name} not implemented! define a load_<<vocoder_name>> method for it"
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
denoiser = Denoiser(vocoder, mode="zeros")
|
| 104 |
+
print(f"[+] {vocoder_name} loaded!")
|
| 105 |
+
return vocoder, denoiser
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def load_matcha(model_name, checkpoint_path, device):
|
| 109 |
+
print(f"[!] Loading {model_name}!")
|
| 110 |
+
model = MatchaTTS.load_from_checkpoint(checkpoint_path, map_location=device)
|
| 111 |
+
_ = model.eval()
|
| 112 |
+
|
| 113 |
+
print(f"[+] {model_name} loaded!")
|
| 114 |
+
return model
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def to_waveform(mel, vocoder, denoiser=None):
|
| 118 |
+
audio = vocoder(mel).clamp(-1, 1)
|
| 119 |
+
if denoiser is not None:
|
| 120 |
+
audio = denoiser(audio.squeeze(), strength=0.00025).cpu().squeeze()
|
| 121 |
+
|
| 122 |
+
return audio.cpu().squeeze()
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def save_to_folder(filename: str, output: dict, folder: str):
|
| 126 |
+
folder = Path(folder)
|
| 127 |
+
folder.mkdir(exist_ok=True, parents=True)
|
| 128 |
+
plot_spectrogram_to_numpy(np.array(output["mel"].squeeze().float().cpu()), f"{filename}.png")
|
| 129 |
+
np.save(folder / f"{filename}", output["mel"].cpu().numpy())
|
| 130 |
+
sf.write(folder / f"{filename}.wav", output["waveform"], 22050, "PCM_24")
|
| 131 |
+
return folder.resolve() / f"{filename}.wav"
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def validate_args(args):
|
| 135 |
+
assert (
|
| 136 |
+
args.text or args.file
|
| 137 |
+
), "Either text or file must be provided Matcha-T(ea)TTS need sometext to whisk the waveforms."
|
| 138 |
+
assert args.temperature >= 0, "Sampling temperature cannot be negative"
|
| 139 |
+
assert args.steps > 0, "Number of ODE steps must be greater than 0"
|
| 140 |
+
|
| 141 |
+
if args.checkpoint_path is None:
|
| 142 |
+
# When using pretrained models
|
| 143 |
+
if args.model in SINGLESPEAKER_MODEL:
|
| 144 |
+
args = validate_args_for_single_speaker_model(args)
|
| 145 |
+
|
| 146 |
+
if args.model in MULTISPEAKER_MODEL:
|
| 147 |
+
args = validate_args_for_multispeaker_model(args)
|
| 148 |
+
else:
|
| 149 |
+
# When using a custom model
|
| 150 |
+
if args.vocoder != "hifigan_univ_v1":
|
| 151 |
+
warn_ = "[-] Using custom model checkpoint! I would suggest passing --vocoder hifigan_univ_v1, unless the custom model is trained on LJ Speech."
|
| 152 |
+
warnings.warn(warn_, UserWarning)
|
| 153 |
+
if args.speaking_rate is None:
|
| 154 |
+
args.speaking_rate = 1.0
|
| 155 |
+
|
| 156 |
+
if args.batched:
|
| 157 |
+
assert args.batch_size > 0, "Batch size must be greater than 0"
|
| 158 |
+
assert args.speaking_rate > 0, "Speaking rate must be greater than 0"
|
| 159 |
+
|
| 160 |
+
return args
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def validate_args_for_multispeaker_model(args):
|
| 164 |
+
if args.vocoder is not None:
|
| 165 |
+
if args.vocoder != MULTISPEAKER_MODEL[args.model]["vocoder"]:
|
| 166 |
+
warn_ = f"[-] Using {args.model} model! I would suggest passing --vocoder {MULTISPEAKER_MODEL[args.model]['vocoder']}"
|
| 167 |
+
warnings.warn(warn_, UserWarning)
|
| 168 |
+
else:
|
| 169 |
+
args.vocoder = MULTISPEAKER_MODEL[args.model]["vocoder"]
|
| 170 |
+
|
| 171 |
+
if args.speaking_rate is None:
|
| 172 |
+
args.speaking_rate = MULTISPEAKER_MODEL[args.model]["speaking_rate"]
|
| 173 |
+
|
| 174 |
+
spk_range = MULTISPEAKER_MODEL[args.model]["spk_range"]
|
| 175 |
+
if args.spk is not None:
|
| 176 |
+
assert (
|
| 177 |
+
args.spk >= spk_range[0] and args.spk <= spk_range[-1]
|
| 178 |
+
), f"Speaker ID must be between {spk_range} for this model."
|
| 179 |
+
else:
|
| 180 |
+
available_spk_id = MULTISPEAKER_MODEL[args.model]["spk"]
|
| 181 |
+
warn_ = f"[!] Speaker ID not provided! Using speaker ID {available_spk_id}"
|
| 182 |
+
warnings.warn(warn_, UserWarning)
|
| 183 |
+
args.spk = available_spk_id
|
| 184 |
+
|
| 185 |
+
return args
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def validate_args_for_single_speaker_model(args):
|
| 189 |
+
if args.vocoder is not None:
|
| 190 |
+
if args.vocoder != SINGLESPEAKER_MODEL[args.model]["vocoder"]:
|
| 191 |
+
warn_ = f"[-] Using {args.model} model! I would suggest passing --vocoder {SINGLESPEAKER_MODEL[args.model]['vocoder']}"
|
| 192 |
+
warnings.warn(warn_, UserWarning)
|
| 193 |
+
else:
|
| 194 |
+
args.vocoder = SINGLESPEAKER_MODEL[args.model]["vocoder"]
|
| 195 |
+
|
| 196 |
+
if args.speaking_rate is None:
|
| 197 |
+
args.speaking_rate = SINGLESPEAKER_MODEL[args.model]["speaking_rate"]
|
| 198 |
+
|
| 199 |
+
if args.spk != SINGLESPEAKER_MODEL[args.model]["spk"]:
|
| 200 |
+
warn_ = f"[-] Ignoring speaker id {args.spk} for {args.model}"
|
| 201 |
+
warnings.warn(warn_, UserWarning)
|
| 202 |
+
args.spk = SINGLESPEAKER_MODEL[args.model]["spk"]
|
| 203 |
+
|
| 204 |
+
return args
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
@torch.inference_mode()
|
| 208 |
+
def cli():
|
| 209 |
+
parser = argparse.ArgumentParser(
|
| 210 |
+
description=" 🍵 Matcha-TTS: A fast TTS architecture with conditional flow matching"
|
| 211 |
+
)
|
| 212 |
+
parser.add_argument(
|
| 213 |
+
"--model",
|
| 214 |
+
type=str,
|
| 215 |
+
default="matcha_ljspeech",
|
| 216 |
+
help="Model to use",
|
| 217 |
+
choices=MATCHA_URLS.keys(),
|
| 218 |
+
)
|
| 219 |
+
|
| 220 |
+
parser.add_argument(
|
| 221 |
+
"--checkpoint_path",
|
| 222 |
+
type=str,
|
| 223 |
+
default=None,
|
| 224 |
+
help="Path to the custom model checkpoint",
|
| 225 |
+
)
|
| 226 |
+
|
| 227 |
+
parser.add_argument(
|
| 228 |
+
"--vocoder",
|
| 229 |
+
type=str,
|
| 230 |
+
default=None,
|
| 231 |
+
help="Vocoder to use (default: will use the one suggested with the pretrained model))",
|
| 232 |
+
choices=VOCODER_URLS.keys(),
|
| 233 |
+
)
|
| 234 |
+
parser.add_argument("--text", type=str, default=None, help="Text to synthesize")
|
| 235 |
+
parser.add_argument("--file", type=str, default=None, help="Text file to synthesize")
|
| 236 |
+
parser.add_argument("--spk", type=int, default=None, help="Speaker ID")
|
| 237 |
+
parser.add_argument(
|
| 238 |
+
"--temperature",
|
| 239 |
+
type=float,
|
| 240 |
+
default=0.667,
|
| 241 |
+
help="Variance of the x0 noise (default: 0.667)",
|
| 242 |
+
)
|
| 243 |
+
parser.add_argument(
|
| 244 |
+
"--speaking_rate",
|
| 245 |
+
type=float,
|
| 246 |
+
default=None,
|
| 247 |
+
help="change the speaking rate, a higher value means slower speaking rate (default: 1.0)",
|
| 248 |
+
)
|
| 249 |
+
parser.add_argument("--steps", type=int, default=10, help="Number of ODE steps (default: 10)")
|
| 250 |
+
parser.add_argument("--cpu", action="store_true", help="Use CPU for inference (default: use GPU if available)")
|
| 251 |
+
parser.add_argument(
|
| 252 |
+
"--denoiser_strength",
|
| 253 |
+
type=float,
|
| 254 |
+
default=0.00025,
|
| 255 |
+
help="Strength of the vocoder bias denoiser (default: 0.00025)",
|
| 256 |
+
)
|
| 257 |
+
parser.add_argument(
|
| 258 |
+
"--output_folder",
|
| 259 |
+
type=str,
|
| 260 |
+
default=os.getcwd(),
|
| 261 |
+
help="Output folder to save results (default: current dir)",
|
| 262 |
+
)
|
| 263 |
+
parser.add_argument("--batched", action="store_true", help="Batched inference (default: False)")
|
| 264 |
+
parser.add_argument(
|
| 265 |
+
"--batch_size", type=int, default=32, help="Batch size only useful when --batched (default: 32)"
|
| 266 |
+
)
|
| 267 |
+
|
| 268 |
+
args = parser.parse_args()
|
| 269 |
+
|
| 270 |
+
args = validate_args(args)
|
| 271 |
+
device = get_device(args)
|
| 272 |
+
print_config(args)
|
| 273 |
+
paths = assert_required_models_available(args)
|
| 274 |
+
|
| 275 |
+
if args.checkpoint_path is not None:
|
| 276 |
+
print(f"[🍵] Loading custom model from {args.checkpoint_path}")
|
| 277 |
+
paths["matcha"] = args.checkpoint_path
|
| 278 |
+
args.model = "custom_model"
|
| 279 |
+
|
| 280 |
+
model = load_matcha(args.model, paths["matcha"], device)
|
| 281 |
+
vocoder, denoiser = load_vocoder(args.vocoder, paths["vocoder"], device)
|
| 282 |
+
|
| 283 |
+
texts = get_texts(args)
|
| 284 |
+
|
| 285 |
+
spk = torch.tensor([args.spk], device=device, dtype=torch.long) if args.spk is not None else None
|
| 286 |
+
if len(texts) == 1 or not args.batched:
|
| 287 |
+
unbatched_synthesis(args, device, model, vocoder, denoiser, texts, spk)
|
| 288 |
+
else:
|
| 289 |
+
batched_synthesis(args, device, model, vocoder, denoiser, texts, spk)
|
| 290 |
+
|
| 291 |
+
|
| 292 |
+
class BatchedSynthesisDataset(torch.utils.data.Dataset):
|
| 293 |
+
def __init__(self, processed_texts):
|
| 294 |
+
self.processed_texts = processed_texts
|
| 295 |
+
|
| 296 |
+
def __len__(self):
|
| 297 |
+
return len(self.processed_texts)
|
| 298 |
+
|
| 299 |
+
def __getitem__(self, idx):
|
| 300 |
+
return self.processed_texts[idx]
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
def batched_collate_fn(batch):
|
| 304 |
+
x = []
|
| 305 |
+
x_lengths = []
|
| 306 |
+
|
| 307 |
+
for b in batch:
|
| 308 |
+
x.append(b["x"].squeeze(0))
|
| 309 |
+
x_lengths.append(b["x_lengths"])
|
| 310 |
+
|
| 311 |
+
x = torch.nn.utils.rnn.pad_sequence(x, batch_first=True)
|
| 312 |
+
x_lengths = torch.concat(x_lengths, dim=0)
|
| 313 |
+
return {"x": x, "x_lengths": x_lengths}
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
def batched_synthesis(args, device, model, vocoder, denoiser, texts, spk):
|
| 317 |
+
total_rtf = []
|
| 318 |
+
total_rtf_w = []
|
| 319 |
+
processed_text = [process_text(i, text, "cpu") for i, text in enumerate(texts)]
|
| 320 |
+
dataloader = torch.utils.data.DataLoader(
|
| 321 |
+
BatchedSynthesisDataset(processed_text),
|
| 322 |
+
batch_size=args.batch_size,
|
| 323 |
+
collate_fn=batched_collate_fn,
|
| 324 |
+
num_workers=8,
|
| 325 |
+
)
|
| 326 |
+
for i, batch in enumerate(dataloader):
|
| 327 |
+
i = i + 1
|
| 328 |
+
start_t = dt.datetime.now()
|
| 329 |
+
output = model.synthesise(
|
| 330 |
+
batch["x"].to(device),
|
| 331 |
+
batch["x_lengths"].to(device),
|
| 332 |
+
n_timesteps=args.steps,
|
| 333 |
+
temperature=args.temperature,
|
| 334 |
+
spks=spk,
|
| 335 |
+
length_scale=args.speaking_rate,
|
| 336 |
+
)
|
| 337 |
+
|
| 338 |
+
output["waveform"] = to_waveform(output["mel"], vocoder, denoiser)
|
| 339 |
+
t = (dt.datetime.now() - start_t).total_seconds()
|
| 340 |
+
rtf_w = t * 22050 / (output["waveform"].shape[-1])
|
| 341 |
+
print(f"[🍵-Batch: {i}] Matcha-TTS RTF: {output['rtf']:.4f}")
|
| 342 |
+
print(f"[🍵-Batch: {i}] Matcha-TTS + VOCODER RTF: {rtf_w:.4f}")
|
| 343 |
+
total_rtf.append(output["rtf"])
|
| 344 |
+
total_rtf_w.append(rtf_w)
|
| 345 |
+
for j in range(output["mel"].shape[0]):
|
| 346 |
+
base_name = f"utterance_{j:03d}_speaker_{args.spk:03d}" if args.spk is not None else f"utterance_{j:03d}"
|
| 347 |
+
length = output["mel_lengths"][j]
|
| 348 |
+
new_dict = {"mel": output["mel"][j][:, :length], "waveform": output["waveform"][j][: length * 256]}
|
| 349 |
+
location = save_to_folder(base_name, new_dict, args.output_folder)
|
| 350 |
+
print(f"[🍵-{j}] Waveform saved: {location}")
|
| 351 |
+
|
| 352 |
+
print("".join(["="] * 100))
|
| 353 |
+
print(f"[🍵] Average Matcha-TTS RTF: {np.mean(total_rtf):.4f} ± {np.std(total_rtf)}")
|
| 354 |
+
print(f"[🍵] Average Matcha-TTS + VOCODER RTF: {np.mean(total_rtf_w):.4f} ± {np.std(total_rtf_w)}")
|
| 355 |
+
print("[🍵] Enjoy the freshly whisked 🍵 Matcha-TTS!")
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
def unbatched_synthesis(args, device, model, vocoder, denoiser, texts, spk):
|
| 359 |
+
total_rtf = []
|
| 360 |
+
total_rtf_w = []
|
| 361 |
+
for i, text in enumerate(texts):
|
| 362 |
+
i = i + 1
|
| 363 |
+
base_name = f"utterance_{i:03d}_speaker_{args.spk:03d}" if args.spk is not None else f"utterance_{i:03d}"
|
| 364 |
+
|
| 365 |
+
print("".join(["="] * 100))
|
| 366 |
+
text = text.strip()
|
| 367 |
+
text_processed = process_text(i, text, device)
|
| 368 |
+
|
| 369 |
+
print(f"[🍵] Whisking Matcha-T(ea)TS for: {i}")
|
| 370 |
+
start_t = dt.datetime.now()
|
| 371 |
+
output = model.synthesise(
|
| 372 |
+
text_processed["x"],
|
| 373 |
+
text_processed["x_lengths"],
|
| 374 |
+
n_timesteps=args.steps,
|
| 375 |
+
temperature=args.temperature,
|
| 376 |
+
spks=spk,
|
| 377 |
+
length_scale=args.speaking_rate,
|
| 378 |
+
)
|
| 379 |
+
output["waveform"] = to_waveform(output["mel"], vocoder, denoiser)
|
| 380 |
+
# RTF with HiFiGAN
|
| 381 |
+
t = (dt.datetime.now() - start_t).total_seconds()
|
| 382 |
+
rtf_w = t * 22050 / (output["waveform"].shape[-1])
|
| 383 |
+
print(f"[🍵-{i}] Matcha-TTS RTF: {output['rtf']:.4f}")
|
| 384 |
+
print(f"[🍵-{i}] Matcha-TTS + VOCODER RTF: {rtf_w:.4f}")
|
| 385 |
+
total_rtf.append(output["rtf"])
|
| 386 |
+
total_rtf_w.append(rtf_w)
|
| 387 |
+
|
| 388 |
+
location = save_to_folder(base_name, output, args.output_folder)
|
| 389 |
+
print(f"[+] Waveform saved: {location}")
|
| 390 |
+
|
| 391 |
+
print("".join(["="] * 100))
|
| 392 |
+
print(f"[🍵] Average Matcha-TTS RTF: {np.mean(total_rtf):.4f} ± {np.std(total_rtf)}")
|
| 393 |
+
print(f"[🍵] Average Matcha-TTS + VOCODER RTF: {np.mean(total_rtf_w):.4f} ± {np.std(total_rtf_w)}")
|
| 394 |
+
print("[🍵] Enjoy the freshly whisked 🍵 Matcha-TTS!")
|
| 395 |
+
|
| 396 |
+
|
| 397 |
+
def print_config(args):
|
| 398 |
+
print("[!] Configurations: ")
|
| 399 |
+
print(f"\t- Model: {args.model}")
|
| 400 |
+
print(f"\t- Vocoder: {args.vocoder}")
|
| 401 |
+
print(f"\t- Temperature: {args.temperature}")
|
| 402 |
+
print(f"\t- Speaking rate: {args.speaking_rate}")
|
| 403 |
+
print(f"\t- Number of ODE steps: {args.steps}")
|
| 404 |
+
print(f"\t- Speaker: {args.spk}")
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
def get_device(args):
|
| 408 |
+
if torch.cuda.is_available() and not args.cpu:
|
| 409 |
+
print("[+] GPU Available! Using GPU")
|
| 410 |
+
device = torch.device("cuda")
|
| 411 |
+
else:
|
| 412 |
+
print("[-] GPU not available or forced CPU run! Using CPU")
|
| 413 |
+
device = torch.device("cpu")
|
| 414 |
+
return device
|
| 415 |
+
|
| 416 |
+
|
| 417 |
+
if __name__ == "__main__":
|
| 418 |
+
cli()
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/data/__init__.py
ADDED
|
File without changes
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/data/components/__init__.py
ADDED
|
File without changes
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/data/text_mel_datamodule.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import random
|
| 2 |
+
from typing import Any, Dict, Optional
|
| 3 |
+
|
| 4 |
+
import torch
|
| 5 |
+
import torchaudio as ta
|
| 6 |
+
from lightning import LightningDataModule
|
| 7 |
+
from torch.utils.data.dataloader import DataLoader
|
| 8 |
+
|
| 9 |
+
from matcha.text import text_to_sequence
|
| 10 |
+
from matcha.utils.audio import mel_spectrogram
|
| 11 |
+
from matcha.utils.model import fix_len_compatibility, normalize
|
| 12 |
+
from matcha.utils.utils import intersperse
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def parse_filelist(filelist_path, split_char="|"):
|
| 16 |
+
with open(filelist_path, encoding="utf-8") as f:
|
| 17 |
+
filepaths_and_text = [line.strip().split(split_char) for line in f]
|
| 18 |
+
return filepaths_and_text
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
class TextMelDataModule(LightningDataModule):
|
| 22 |
+
def __init__( # pylint: disable=unused-argument
|
| 23 |
+
self,
|
| 24 |
+
name,
|
| 25 |
+
train_filelist_path,
|
| 26 |
+
valid_filelist_path,
|
| 27 |
+
batch_size,
|
| 28 |
+
num_workers,
|
| 29 |
+
pin_memory,
|
| 30 |
+
cleaners,
|
| 31 |
+
add_blank,
|
| 32 |
+
n_spks,
|
| 33 |
+
n_fft,
|
| 34 |
+
n_feats,
|
| 35 |
+
sample_rate,
|
| 36 |
+
hop_length,
|
| 37 |
+
win_length,
|
| 38 |
+
f_min,
|
| 39 |
+
f_max,
|
| 40 |
+
data_statistics,
|
| 41 |
+
seed,
|
| 42 |
+
):
|
| 43 |
+
super().__init__()
|
| 44 |
+
|
| 45 |
+
# this line allows to access init params with 'self.hparams' attribute
|
| 46 |
+
# also ensures init params will be stored in ckpt
|
| 47 |
+
self.save_hyperparameters(logger=False)
|
| 48 |
+
|
| 49 |
+
def setup(self, stage: Optional[str] = None): # pylint: disable=unused-argument
|
| 50 |
+
"""Load data. Set variables: `self.data_train`, `self.data_val`, `self.data_test`.
|
| 51 |
+
|
| 52 |
+
This method is called by lightning with both `trainer.fit()` and `trainer.test()`, so be
|
| 53 |
+
careful not to execute things like random split twice!
|
| 54 |
+
"""
|
| 55 |
+
# load and split datasets only if not loaded already
|
| 56 |
+
|
| 57 |
+
self.trainset = TextMelDataset( # pylint: disable=attribute-defined-outside-init
|
| 58 |
+
self.hparams.train_filelist_path,
|
| 59 |
+
self.hparams.n_spks,
|
| 60 |
+
self.hparams.cleaners,
|
| 61 |
+
self.hparams.add_blank,
|
| 62 |
+
self.hparams.n_fft,
|
| 63 |
+
self.hparams.n_feats,
|
| 64 |
+
self.hparams.sample_rate,
|
| 65 |
+
self.hparams.hop_length,
|
| 66 |
+
self.hparams.win_length,
|
| 67 |
+
self.hparams.f_min,
|
| 68 |
+
self.hparams.f_max,
|
| 69 |
+
self.hparams.data_statistics,
|
| 70 |
+
self.hparams.seed,
|
| 71 |
+
)
|
| 72 |
+
self.validset = TextMelDataset( # pylint: disable=attribute-defined-outside-init
|
| 73 |
+
self.hparams.valid_filelist_path,
|
| 74 |
+
self.hparams.n_spks,
|
| 75 |
+
self.hparams.cleaners,
|
| 76 |
+
self.hparams.add_blank,
|
| 77 |
+
self.hparams.n_fft,
|
| 78 |
+
self.hparams.n_feats,
|
| 79 |
+
self.hparams.sample_rate,
|
| 80 |
+
self.hparams.hop_length,
|
| 81 |
+
self.hparams.win_length,
|
| 82 |
+
self.hparams.f_min,
|
| 83 |
+
self.hparams.f_max,
|
| 84 |
+
self.hparams.data_statistics,
|
| 85 |
+
self.hparams.seed,
|
| 86 |
+
)
|
| 87 |
+
|
| 88 |
+
def train_dataloader(self):
|
| 89 |
+
return DataLoader(
|
| 90 |
+
dataset=self.trainset,
|
| 91 |
+
batch_size=self.hparams.batch_size,
|
| 92 |
+
num_workers=self.hparams.num_workers,
|
| 93 |
+
pin_memory=self.hparams.pin_memory,
|
| 94 |
+
shuffle=True,
|
| 95 |
+
collate_fn=TextMelBatchCollate(self.hparams.n_spks),
|
| 96 |
+
)
|
| 97 |
+
|
| 98 |
+
def val_dataloader(self):
|
| 99 |
+
return DataLoader(
|
| 100 |
+
dataset=self.validset,
|
| 101 |
+
batch_size=self.hparams.batch_size,
|
| 102 |
+
num_workers=self.hparams.num_workers,
|
| 103 |
+
pin_memory=self.hparams.pin_memory,
|
| 104 |
+
shuffle=False,
|
| 105 |
+
collate_fn=TextMelBatchCollate(self.hparams.n_spks),
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
def teardown(self, stage: Optional[str] = None):
|
| 109 |
+
"""Clean up after fit or test."""
|
| 110 |
+
pass # pylint: disable=unnecessary-pass
|
| 111 |
+
|
| 112 |
+
def state_dict(self): # pylint: disable=no-self-use
|
| 113 |
+
"""Extra things to save to checkpoint."""
|
| 114 |
+
return {}
|
| 115 |
+
|
| 116 |
+
def load_state_dict(self, state_dict: Dict[str, Any]):
|
| 117 |
+
"""Things to do when loading checkpoint."""
|
| 118 |
+
pass # pylint: disable=unnecessary-pass
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
class TextMelDataset(torch.utils.data.Dataset):
|
| 122 |
+
def __init__(
|
| 123 |
+
self,
|
| 124 |
+
filelist_path,
|
| 125 |
+
n_spks,
|
| 126 |
+
cleaners,
|
| 127 |
+
add_blank=True,
|
| 128 |
+
n_fft=1024,
|
| 129 |
+
n_mels=80,
|
| 130 |
+
sample_rate=22050,
|
| 131 |
+
hop_length=256,
|
| 132 |
+
win_length=1024,
|
| 133 |
+
f_min=0.0,
|
| 134 |
+
f_max=8000,
|
| 135 |
+
data_parameters=None,
|
| 136 |
+
seed=None,
|
| 137 |
+
):
|
| 138 |
+
self.filepaths_and_text = parse_filelist(filelist_path)
|
| 139 |
+
self.n_spks = n_spks
|
| 140 |
+
self.cleaners = cleaners
|
| 141 |
+
self.add_blank = add_blank
|
| 142 |
+
self.n_fft = n_fft
|
| 143 |
+
self.n_mels = n_mels
|
| 144 |
+
self.sample_rate = sample_rate
|
| 145 |
+
self.hop_length = hop_length
|
| 146 |
+
self.win_length = win_length
|
| 147 |
+
self.f_min = f_min
|
| 148 |
+
self.f_max = f_max
|
| 149 |
+
if data_parameters is not None:
|
| 150 |
+
self.data_parameters = data_parameters
|
| 151 |
+
else:
|
| 152 |
+
self.data_parameters = {"mel_mean": 0, "mel_std": 1}
|
| 153 |
+
random.seed(seed)
|
| 154 |
+
random.shuffle(self.filepaths_and_text)
|
| 155 |
+
|
| 156 |
+
def get_datapoint(self, filepath_and_text):
|
| 157 |
+
if self.n_spks > 1:
|
| 158 |
+
filepath, spk, text = (
|
| 159 |
+
filepath_and_text[0],
|
| 160 |
+
int(filepath_and_text[1]),
|
| 161 |
+
filepath_and_text[2],
|
| 162 |
+
)
|
| 163 |
+
else:
|
| 164 |
+
filepath, text = filepath_and_text[0], filepath_and_text[1]
|
| 165 |
+
spk = None
|
| 166 |
+
|
| 167 |
+
text = self.get_text(text, add_blank=self.add_blank)
|
| 168 |
+
mel = self.get_mel(filepath)
|
| 169 |
+
|
| 170 |
+
return {"x": text, "y": mel, "spk": spk}
|
| 171 |
+
|
| 172 |
+
def get_mel(self, filepath):
|
| 173 |
+
audio, sr = ta.load(filepath)
|
| 174 |
+
assert sr == self.sample_rate
|
| 175 |
+
mel = mel_spectrogram(
|
| 176 |
+
audio,
|
| 177 |
+
self.n_fft,
|
| 178 |
+
self.n_mels,
|
| 179 |
+
self.sample_rate,
|
| 180 |
+
self.hop_length,
|
| 181 |
+
self.win_length,
|
| 182 |
+
self.f_min,
|
| 183 |
+
self.f_max,
|
| 184 |
+
center=False,
|
| 185 |
+
).squeeze()
|
| 186 |
+
mel = normalize(mel, self.data_parameters["mel_mean"], self.data_parameters["mel_std"])
|
| 187 |
+
return mel
|
| 188 |
+
|
| 189 |
+
def get_text(self, text, add_blank=True):
|
| 190 |
+
text_norm = text_to_sequence(text, self.cleaners)
|
| 191 |
+
if self.add_blank:
|
| 192 |
+
text_norm = intersperse(text_norm, 0)
|
| 193 |
+
text_norm = torch.IntTensor(text_norm)
|
| 194 |
+
return text_norm
|
| 195 |
+
|
| 196 |
+
def __getitem__(self, index):
|
| 197 |
+
datapoint = self.get_datapoint(self.filepaths_and_text[index])
|
| 198 |
+
return datapoint
|
| 199 |
+
|
| 200 |
+
def __len__(self):
|
| 201 |
+
return len(self.filepaths_and_text)
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
class TextMelBatchCollate:
|
| 205 |
+
def __init__(self, n_spks):
|
| 206 |
+
self.n_spks = n_spks
|
| 207 |
+
|
| 208 |
+
def __call__(self, batch):
|
| 209 |
+
B = len(batch)
|
| 210 |
+
y_max_length = max([item["y"].shape[-1] for item in batch])
|
| 211 |
+
y_max_length = fix_len_compatibility(y_max_length)
|
| 212 |
+
x_max_length = max([item["x"].shape[-1] for item in batch])
|
| 213 |
+
n_feats = batch[0]["y"].shape[-2]
|
| 214 |
+
|
| 215 |
+
y = torch.zeros((B, n_feats, y_max_length), dtype=torch.float32)
|
| 216 |
+
x = torch.zeros((B, x_max_length), dtype=torch.long)
|
| 217 |
+
y_lengths, x_lengths = [], []
|
| 218 |
+
spks = []
|
| 219 |
+
for i, item in enumerate(batch):
|
| 220 |
+
y_, x_ = item["y"], item["x"]
|
| 221 |
+
y_lengths.append(y_.shape[-1])
|
| 222 |
+
x_lengths.append(x_.shape[-1])
|
| 223 |
+
y[i, :, : y_.shape[-1]] = y_
|
| 224 |
+
x[i, : x_.shape[-1]] = x_
|
| 225 |
+
spks.append(item["spk"])
|
| 226 |
+
|
| 227 |
+
y_lengths = torch.tensor(y_lengths, dtype=torch.long)
|
| 228 |
+
x_lengths = torch.tensor(x_lengths, dtype=torch.long)
|
| 229 |
+
spks = torch.tensor(spks, dtype=torch.long) if self.n_spks > 1 else None
|
| 230 |
+
|
| 231 |
+
return {"x": x, "x_lengths": x_lengths, "y": y, "y_lengths": y_lengths, "spks": spks}
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/hifigan/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2020 Jungil Kong
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
almeval/models/kimi_audio/kimia_infer/models/tokenizer/glm4/third_party/Matcha-TTS/matcha/hifigan/README.md
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HiFi-GAN: Generative Adversarial Networks for Efficient and High Fidelity Speech Synthesis
|
| 2 |
+
|
| 3 |
+
### Jungil Kong, Jaehyeon Kim, Jaekyoung Bae
|
| 4 |
+
|
| 5 |
+
In our [paper](https://arxiv.org/abs/2010.05646),
|
| 6 |
+
we proposed HiFi-GAN: a GAN-based model capable of generating high fidelity speech efficiently.<br/>
|
| 7 |
+
We provide our implementation and pretrained models as open source in this repository.
|
| 8 |
+
|
| 9 |
+
**Abstract :**
|
| 10 |
+
Several recent work on speech synthesis have employed generative adversarial networks (GANs) to produce raw waveforms.
|
| 11 |
+
Although such methods improve the sampling efficiency and memory usage,
|
| 12 |
+
their sample quality has not yet reached that of autoregressive and flow-based generative models.
|
| 13 |
+
In this work, we propose HiFi-GAN, which achieves both efficient and high-fidelity speech synthesis.
|
| 14 |
+
As speech audio consists of sinusoidal signals with various periods,
|
| 15 |
+
we demonstrate that modeling periodic patterns of an audio is crucial for enhancing sample quality.
|
| 16 |
+
A subjective human evaluation (mean opinion score, MOS) of a single speaker dataset indicates that our proposed method
|
| 17 |
+
demonstrates similarity to human quality while generating 22.05 kHz high-fidelity audio 167.9 times faster than
|
| 18 |
+
real-time on a single V100 GPU. We further show the generality of HiFi-GAN to the mel-spectrogram inversion of unseen
|
| 19 |
+
speakers and end-to-end speech synthesis. Finally, a small footprint version of HiFi-GAN generates samples 13.4 times
|
| 20 |
+
faster than real-time on CPU with comparable quality to an autoregressive counterpart.
|
| 21 |
+
|
| 22 |
+
Visit our [demo website](https://jik876.github.io/hifi-gan-demo/) for audio samples.
|
| 23 |
+
|
| 24 |
+
## Pre-requisites
|
| 25 |
+
|
| 26 |
+
1. Python >= 3.6
|
| 27 |
+
2. Clone this repository.
|
| 28 |
+
3. Install python requirements. Please refer [requirements.txt](requirements.txt)
|
| 29 |
+
4. Download and extract the [LJ Speech dataset](https://keithito.com/LJ-Speech-Dataset/).
|
| 30 |
+
And move all wav files to `LJSpeech-1.1/wavs`
|
| 31 |
+
|
| 32 |
+
## Training
|
| 33 |
+
|
| 34 |
+
```
|
| 35 |
+
python train.py --config config_v1.json
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
To train V2 or V3 Generator, replace `config_v1.json` with `config_v2.json` or `config_v3.json`.<br>
|
| 39 |
+
Checkpoints and copy of the configuration file are saved in `cp_hifigan` directory by default.<br>
|
| 40 |
+
You can change the path by adding `--checkpoint_path` option.
|
| 41 |
+
|
| 42 |
+
Validation loss during training with V1 generator.<br>
|
| 43 |
+

|
| 44 |
+
|
| 45 |
+
## Pretrained Model
|
| 46 |
+
|
| 47 |
+
You can also use pretrained models we provide.<br/>
|
| 48 |
+
[Download pretrained models](https://drive.google.com/drive/folders/1-eEYTB5Av9jNql0WGBlRoi-WH2J7bp5Y?usp=sharing)<br/>
|
| 49 |
+
Details of each folder are as in follows:
|
| 50 |
+
|
| 51 |
+
| Folder Name | Generator | Dataset | Fine-Tuned |
|
| 52 |
+
| ------------ | --------- | --------- | ------------------------------------------------------ |
|
| 53 |
+
| LJ_V1 | V1 | LJSpeech | No |
|
| 54 |
+
| LJ_V2 | V2 | LJSpeech | No |
|
| 55 |
+
| LJ_V3 | V3 | LJSpeech | No |
|
| 56 |
+
| LJ_FT_T2_V1 | V1 | LJSpeech | Yes ([Tacotron2](https://github.com/NVIDIA/tacotron2)) |
|
| 57 |
+
| LJ_FT_T2_V2 | V2 | LJSpeech | Yes ([Tacotron2](https://github.com/NVIDIA/tacotron2)) |
|
| 58 |
+
| LJ_FT_T2_V3 | V3 | LJSpeech | Yes ([Tacotron2](https://github.com/NVIDIA/tacotron2)) |
|
| 59 |
+
| VCTK_V1 | V1 | VCTK | No |
|
| 60 |
+
| VCTK_V2 | V2 | VCTK | No |
|
| 61 |
+
| VCTK_V3 | V3 | VCTK | No |
|
| 62 |
+
| UNIVERSAL_V1 | V1 | Universal | No |
|
| 63 |
+
|
| 64 |
+
We provide the universal model with discriminator weights that can be used as a base for transfer learning to other datasets.
|
| 65 |
+
|
| 66 |
+
## Fine-Tuning
|
| 67 |
+
|
| 68 |
+
1. Generate mel-spectrograms in numpy format using [Tacotron2](https://github.com/NVIDIA/tacotron2) with teacher-forcing.<br/>
|
| 69 |
+
The file name of the generated mel-spectrogram should match the audio file and the extension should be `.npy`.<br/>
|
| 70 |
+
Example:
|
| 71 |
+
` Audio File : LJ001-0001.wav
|
| 72 |
+
Mel-Spectrogram File : LJ001-0001.npy`
|
| 73 |
+
2. Create `ft_dataset` folder and copy the generated mel-spectrogram files into it.<br/>
|
| 74 |
+
3. Run the following command.
|
| 75 |
+
```
|
| 76 |
+
python train.py --fine_tuning True --config config_v1.json
|
| 77 |
+
```
|
| 78 |
+
For other command line options, please refer to the training section.
|
| 79 |
+
|
| 80 |
+
## Inference from wav file
|
| 81 |
+
|
| 82 |
+
1. Make `test_files` directory and copy wav files into the directory.
|
| 83 |
+
2. Run the following command.
|
| 84 |
+
` python inference.py --checkpoint_file [generator checkpoint file path]`
|
| 85 |
+
Generated wav files are saved in `generated_files` by default.<br>
|
| 86 |
+
You can change the path by adding `--output_dir` option.
|
| 87 |
+
|
| 88 |
+
## Inference for end-to-end speech synthesis
|
| 89 |
+
|
| 90 |
+
1. Make `test_mel_files` directory and copy generated mel-spectrogram files into the directory.<br>
|
| 91 |
+
You can generate mel-spectrograms using [Tacotron2](https://github.com/NVIDIA/tacotron2),
|
| 92 |
+
[Glow-TTS](https://github.com/jaywalnut310/glow-tts) and so forth.
|
| 93 |
+
2. Run the following command.
|
| 94 |
+
` python inference_e2e.py --checkpoint_file [generator checkpoint file path]`
|
| 95 |
+
Generated wav files are saved in `generated_files_from_mel` by default.<br>
|
| 96 |
+
You can change the path by adding `--output_dir` option.
|
| 97 |
+
|
| 98 |
+
## Acknowledgements
|
| 99 |
+
|
| 100 |
+
We referred to [WaveGlow](https://github.com/NVIDIA/waveglow), [MelGAN](https://github.com/descriptinc/melgan-neurips)
|
| 101 |
+
and [Tacotron2](https://github.com/NVIDIA/tacotron2) to implement this.
|