xinference 1.10.0__py3-none-any.whl → 1.10.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xinference might be problematic. Click here for more details.
- xinference/_version.py +3 -3
- xinference/api/restful_api.py +11 -28
- xinference/client/restful/async_restful_client.py +20 -3
- xinference/client/restful/restful_client.py +20 -3
- xinference/core/supervisor.py +87 -53
- xinference/core/worker.py +10 -0
- xinference/deploy/cmdline.py +15 -0
- xinference/model/audio/core.py +21 -6
- xinference/model/audio/indextts2.py +166 -0
- xinference/model/audio/model_spec.json +38 -1
- xinference/model/image/model_spec.json +69 -0
- xinference/model/image/stable_diffusion/core.py +13 -4
- xinference/model/llm/__init__.py +4 -0
- xinference/model/llm/llm_family.json +464 -2
- xinference/model/llm/sglang/core.py +30 -11
- xinference/model/llm/tool_parsers/deepseek_r1_tool_parser.py +94 -32
- xinference/model/llm/transformers/multimodal/qwen2_vl.py +34 -8
- xinference/model/llm/utils.py +12 -9
- xinference/model/llm/vllm/core.py +93 -17
- xinference/thirdparty/audiotools/__init__.py +10 -0
- xinference/thirdparty/audiotools/core/__init__.py +4 -0
- xinference/thirdparty/audiotools/core/audio_signal.py +1682 -0
- xinference/thirdparty/audiotools/core/display.py +194 -0
- xinference/thirdparty/audiotools/core/dsp.py +390 -0
- xinference/thirdparty/audiotools/core/effects.py +647 -0
- xinference/thirdparty/audiotools/core/ffmpeg.py +211 -0
- xinference/thirdparty/audiotools/core/loudness.py +320 -0
- xinference/thirdparty/audiotools/core/playback.py +252 -0
- xinference/thirdparty/audiotools/core/templates/__init__.py +0 -0
- xinference/thirdparty/audiotools/core/templates/headers.html +322 -0
- xinference/thirdparty/audiotools/core/templates/pandoc.css +407 -0
- xinference/thirdparty/audiotools/core/templates/widget.html +52 -0
- xinference/thirdparty/audiotools/core/util.py +671 -0
- xinference/thirdparty/audiotools/core/whisper.py +97 -0
- xinference/thirdparty/audiotools/data/__init__.py +3 -0
- xinference/thirdparty/audiotools/data/datasets.py +517 -0
- xinference/thirdparty/audiotools/data/preprocess.py +81 -0
- xinference/thirdparty/audiotools/data/transforms.py +1592 -0
- xinference/thirdparty/audiotools/metrics/__init__.py +6 -0
- xinference/thirdparty/audiotools/metrics/distance.py +131 -0
- xinference/thirdparty/audiotools/metrics/quality.py +159 -0
- xinference/thirdparty/audiotools/metrics/spectral.py +247 -0
- xinference/thirdparty/audiotools/ml/__init__.py +5 -0
- xinference/thirdparty/audiotools/ml/accelerator.py +184 -0
- xinference/thirdparty/audiotools/ml/decorators.py +440 -0
- xinference/thirdparty/audiotools/ml/experiment.py +90 -0
- xinference/thirdparty/audiotools/ml/layers/__init__.py +2 -0
- xinference/thirdparty/audiotools/ml/layers/base.py +328 -0
- xinference/thirdparty/audiotools/ml/layers/spectral_gate.py +127 -0
- xinference/thirdparty/audiotools/post.py +140 -0
- xinference/thirdparty/audiotools/preference.py +600 -0
- xinference/thirdparty/indextts/BigVGAN/ECAPA_TDNN.py +656 -0
- xinference/thirdparty/indextts/BigVGAN/__init__.py +0 -0
- xinference/thirdparty/indextts/BigVGAN/activations.py +122 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/__init__.py +0 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/.gitignore +1 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/__init__.py +0 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/activation1d.py +76 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/anti_alias_activation.cpp +23 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/anti_alias_activation_cuda.cu +256 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/compat.h +29 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/load.py +121 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/type_shim.h +92 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/torch/__init__.py +6 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/torch/act.py +31 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/torch/filter.py +102 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/torch/resample.py +58 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_torch/__init__.py +6 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_torch/act.py +29 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_torch/filter.py +96 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_torch/resample.py +49 -0
- xinference/thirdparty/indextts/BigVGAN/bigvgan.py +534 -0
- xinference/thirdparty/indextts/BigVGAN/models.py +451 -0
- xinference/thirdparty/indextts/BigVGAN/nnet/CNN.py +546 -0
- xinference/thirdparty/indextts/BigVGAN/nnet/__init__.py +0 -0
- xinference/thirdparty/indextts/BigVGAN/nnet/linear.py +89 -0
- xinference/thirdparty/indextts/BigVGAN/nnet/normalization.py +670 -0
- xinference/thirdparty/indextts/BigVGAN/utils.py +101 -0
- xinference/thirdparty/indextts/__init__.py +0 -0
- xinference/thirdparty/indextts/cli.py +65 -0
- xinference/thirdparty/indextts/gpt/__init__.py +0 -0
- xinference/thirdparty/indextts/gpt/conformer/__init__.py +0 -0
- xinference/thirdparty/indextts/gpt/conformer/attention.py +312 -0
- xinference/thirdparty/indextts/gpt/conformer/embedding.py +163 -0
- xinference/thirdparty/indextts/gpt/conformer/subsampling.py +348 -0
- xinference/thirdparty/indextts/gpt/conformer_encoder.py +520 -0
- xinference/thirdparty/indextts/gpt/model.py +713 -0
- xinference/thirdparty/indextts/gpt/model_v2.py +747 -0
- xinference/thirdparty/indextts/gpt/perceiver.py +317 -0
- xinference/thirdparty/indextts/gpt/transformers_beam_search.py +1013 -0
- xinference/thirdparty/indextts/gpt/transformers_generation_utils.py +4747 -0
- xinference/thirdparty/indextts/gpt/transformers_gpt2.py +1878 -0
- xinference/thirdparty/indextts/gpt/transformers_modeling_utils.py +5525 -0
- xinference/thirdparty/indextts/infer.py +690 -0
- xinference/thirdparty/indextts/infer_v2.py +739 -0
- xinference/thirdparty/indextts/s2mel/dac/__init__.py +16 -0
- xinference/thirdparty/indextts/s2mel/dac/__main__.py +36 -0
- xinference/thirdparty/indextts/s2mel/dac/model/__init__.py +4 -0
- xinference/thirdparty/indextts/s2mel/dac/model/base.py +294 -0
- xinference/thirdparty/indextts/s2mel/dac/model/dac.py +400 -0
- xinference/thirdparty/indextts/s2mel/dac/model/discriminator.py +228 -0
- xinference/thirdparty/indextts/s2mel/dac/model/encodec.py +320 -0
- xinference/thirdparty/indextts/s2mel/dac/nn/__init__.py +3 -0
- xinference/thirdparty/indextts/s2mel/dac/nn/layers.py +33 -0
- xinference/thirdparty/indextts/s2mel/dac/nn/loss.py +368 -0
- xinference/thirdparty/indextts/s2mel/dac/nn/quantize.py +339 -0
- xinference/thirdparty/indextts/s2mel/dac/utils/__init__.py +123 -0
- xinference/thirdparty/indextts/s2mel/dac/utils/decode.py +95 -0
- xinference/thirdparty/indextts/s2mel/dac/utils/encode.py +94 -0
- xinference/thirdparty/indextts/s2mel/hf_utils.py +12 -0
- xinference/thirdparty/indextts/s2mel/modules/alias_free_torch/__init__.py +5 -0
- xinference/thirdparty/indextts/s2mel/modules/alias_free_torch/act.py +29 -0
- xinference/thirdparty/indextts/s2mel/modules/alias_free_torch/filter.py +96 -0
- xinference/thirdparty/indextts/s2mel/modules/alias_free_torch/resample.py +57 -0
- xinference/thirdparty/indextts/s2mel/modules/audio.py +82 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/activations.py +120 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/__init__.py +0 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/activation1d.py +77 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/anti_alias_activation.cpp +23 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/anti_alias_activation_cuda.cu +246 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/compat.h +29 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/load.py +86 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/type_shim.h +92 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/torch/__init__.py +6 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/torch/act.py +30 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/torch/filter.py +101 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/torch/resample.py +58 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/bigvgan.py +492 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/config.json +63 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/env.py +18 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/meldataset.py +354 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/utils.py +99 -0
- xinference/thirdparty/indextts/s2mel/modules/campplus/DTDNN.py +115 -0
- xinference/thirdparty/indextts/s2mel/modules/campplus/classifier.py +70 -0
- xinference/thirdparty/indextts/s2mel/modules/campplus/layers.py +253 -0
- xinference/thirdparty/indextts/s2mel/modules/commons.py +632 -0
- xinference/thirdparty/indextts/s2mel/modules/diffusion_transformer.py +257 -0
- xinference/thirdparty/indextts/s2mel/modules/encodec.py +292 -0
- xinference/thirdparty/indextts/s2mel/modules/flow_matching.py +171 -0
- xinference/thirdparty/indextts/s2mel/modules/gpt_fast/generate.py +436 -0
- xinference/thirdparty/indextts/s2mel/modules/gpt_fast/model.py +360 -0
- xinference/thirdparty/indextts/s2mel/modules/gpt_fast/quantize.py +622 -0
- xinference/thirdparty/indextts/s2mel/modules/hifigan/f0_predictor.py +55 -0
- xinference/thirdparty/indextts/s2mel/modules/hifigan/generator.py +454 -0
- xinference/thirdparty/indextts/s2mel/modules/layers.py +354 -0
- xinference/thirdparty/indextts/s2mel/modules/length_regulator.py +141 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/__init__.py +0 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/api.py +186 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/attentions.py +465 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/checkpoints_v2/converter/config.json +57 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/commons.py +160 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/mel_processing.py +183 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/models.py +499 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/modules.py +598 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/openvoice_app.py +275 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/se_extractor.py +153 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/transforms.py +209 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/utils.py +194 -0
- xinference/thirdparty/indextts/s2mel/modules/quantize.py +229 -0
- xinference/thirdparty/indextts/s2mel/modules/rmvpe.py +631 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/__init__.py +4 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/heads.py +164 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/helpers.py +71 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/loss.py +114 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/models.py +118 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/modules.py +213 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/pretrained.py +51 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/spectral_ops.py +192 -0
- xinference/thirdparty/indextts/s2mel/modules/wavenet.py +174 -0
- xinference/thirdparty/indextts/s2mel/optimizers.py +96 -0
- xinference/thirdparty/indextts/s2mel/wav2vecbert_extract.py +148 -0
- xinference/thirdparty/indextts/utils/__init__.py +0 -0
- xinference/thirdparty/indextts/utils/arch_util.py +120 -0
- xinference/thirdparty/indextts/utils/checkpoint.py +34 -0
- xinference/thirdparty/indextts/utils/common.py +121 -0
- xinference/thirdparty/indextts/utils/feature_extractors.py +50 -0
- xinference/thirdparty/indextts/utils/front.py +536 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/__init__.py +0 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/codec.py +427 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/__init__.py +11 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/factorized_vector_quantize.py +150 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/lookup_free_quantize.py +77 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/residual_vq.py +177 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/vector_quantize.py +401 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/vocos.py +881 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/codec_dataset.py +264 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/codec_inference.py +515 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/codec_sampler.py +126 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/codec_trainer.py +166 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/__init__.py +0 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/alias_free_torch/__init__.py +5 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/alias_free_torch/act.py +29 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/alias_free_torch/filter.py +96 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/alias_free_torch/resample.py +57 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/facodec_dataset.py +98 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/facodec_inference.py +137 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/facodec_trainer.py +776 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/JDC/__init__.py +1 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/JDC/bst.t7 +0 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/JDC/model.py +219 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/attentions.py +437 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/commons.py +331 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/gradient_reversal.py +35 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/layers.py +460 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/quantize.py +741 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/style_encoder.py +110 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/wavenet.py +224 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/optimizer.py +104 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/kmeans/repcodec_model.py +210 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/kmeans/vocos.py +850 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/melvqgan/melspec.py +108 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/README.md +216 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/__init__.py +6 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/alias_free_torch/__init__.py +5 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/alias_free_torch/act.py +29 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/alias_free_torch/filter.py +96 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/alias_free_torch/resample.py +57 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/facodec.py +1222 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/gradient_reversal.py +35 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/melspec.py +102 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/quantize/__init__.py +7 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/quantize/fvq.py +116 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/quantize/rvq.py +87 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/transformer.py +234 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/model.py +184 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/__init__.py +27 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/conv.py +346 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/lstm.py +46 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/norm.py +37 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/__init__.py +14 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/ac.py +317 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/core_vq.py +388 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/distrib.py +135 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/vq.py +125 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/seanet.py +414 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/vevo/vevo_repcodec.py +592 -0
- xinference/thirdparty/indextts/utils/maskgct/models/tts/maskgct/ckpt/wav2vec2bert_stats.pt +0 -0
- xinference/thirdparty/indextts/utils/maskgct/models/tts/maskgct/llama_nar.py +650 -0
- xinference/thirdparty/indextts/utils/maskgct/models/tts/maskgct/maskgct_s2a.py +503 -0
- xinference/thirdparty/indextts/utils/maskgct_utils.py +259 -0
- xinference/thirdparty/indextts/utils/text_utils.py +41 -0
- xinference/thirdparty/indextts/utils/typical_sampling.py +30 -0
- xinference/thirdparty/indextts/utils/utils.py +93 -0
- xinference/thirdparty/indextts/utils/webui_utils.py +42 -0
- xinference/thirdparty/indextts/utils/xtransformers.py +1247 -0
- xinference/thirdparty/indextts/vqvae/__init__.py +0 -0
- xinference/thirdparty/indextts/vqvae/xtts_dvae.py +395 -0
- xinference/ui/gradio/media_interface.py +66 -8
- xinference/ui/web/ui/build/asset-manifest.json +6 -6
- xinference/ui/web/ui/build/index.html +1 -1
- xinference/ui/web/ui/build/static/css/main.5ea97072.css +2 -0
- xinference/ui/web/ui/build/static/css/main.5ea97072.css.map +1 -0
- xinference/ui/web/ui/build/static/js/main.d192c4f3.js +3 -0
- xinference/ui/web/ui/build/static/js/{main.1086c759.js.LICENSE.txt → main.d192c4f3.js.LICENSE.txt} +0 -7
- xinference/ui/web/ui/build/static/js/main.d192c4f3.js.map +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/089c38df5f52348d212ed868dda5c518a42e0c2762caed4175487c0405830c35.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/2b6e3a5b6eb2c5c5f2d007e68cd46c372721cd52bf63508adcdb21ecf79241d8.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/2d887825fd07a56f872eda4420da25fba0b5b62a23bdcc6c6da1a5281887f618.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/4001f9c3e64e73a4f2158826650c174a59d5e3f89ddecddf17cbb6bb688cc4ca.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/4a7018a69e6b7f90fc313248c2aa86f2a8f1eb1db120df586047a8023549b44b.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/64b12aaa1c1d1bf53820ada8a63769067c0ccc5aab46b32348eb1917ae7f2a11.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/7275b67c78ec76ce38a686bb8a576d8c9cecf54e1573614c84859d538efb9be5.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/a68b6ee3b31eadc051fb95ce8f8ccb9c2e8b52c60f290dbab545a1917e065282.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/ae8771cc37693feb160fa8727231312a0c54ef2d1d1ca893be568cd70016ca7e.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/bb4e8722d2d41d87f1fce3661bc8937bffe9448e231fc5f0462630849e851592.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/be6aada1ee4adc2bbf65dbe56d17db32bb3b5478be05d6b527805a8ba6cfb2b9.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/de91c352653c233cf0cb6674e6e04049a44fd0e1156560de65d5c4620521391e.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/e85f7002fc325c83b9c9cd8a1619e5b3ebc701d30e811afc284b88e6ae710cb5.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/e8b603c78944bf3d213639078bfe155ff5c0dfa4048a93cbb967cad6a4eb4ff3.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f05535160a508b2a312de546a6de234776c613db276479ea4253c0b1bdeeb7d6.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f09ba9e11106bd59a0de10cc85c55084097729dcab575f43dfcf07375961ed87.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f995a2425dfb0822fd07127f66ffe9b026883bc156b402eb8bd0b83d52460a93.json +1 -0
- xinference/ui/web/ui/node_modules/.package-lock.json +0 -33
- xinference/ui/web/ui/package-lock.json +0 -34
- xinference/ui/web/ui/package.json +0 -1
- xinference/ui/web/ui/src/locales/en.json +9 -3
- xinference/ui/web/ui/src/locales/ja.json +9 -3
- xinference/ui/web/ui/src/locales/ko.json +9 -3
- xinference/ui/web/ui/src/locales/zh.json +9 -3
- {xinference-1.10.0.dist-info → xinference-1.10.1.dist-info}/METADATA +18 -2
- {xinference-1.10.0.dist-info → xinference-1.10.1.dist-info}/RECORD +285 -67
- xinference/ui/web/ui/build/static/css/main.013f296b.css +0 -2
- xinference/ui/web/ui/build/static/css/main.013f296b.css.map +0 -1
- xinference/ui/web/ui/build/static/js/main.1086c759.js +0 -3
- xinference/ui/web/ui/build/static/js/main.1086c759.js.map +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/0b0f77000cc1b482ca091cfbcae511dfe02f08916971645fad21d0b1234d04a2.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/1c5f8ff423a7c9202bea60b15680f04b1e9964b445b0da3f86c6ff70cf24e797.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/44ce7993e344980e3ed4f13e8f69237d4a5dfc60e37ca6b54f51f8ee1357bd67.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/4aec1cc414ac3ebb3481d3d915e4db597d9127de813291346eacb8554ab170d4.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/644cfec52f3c57a6e222ce60f112237a1efefe9835efd9aad857a685f53d8eed.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/663436f72af53fe0d72394f56d003fa4e0bba489e5bb4e483fd34b00f84637f7.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/69db82ca9bfe27fe417cc6cf2b1716b09be9c6f0cd198530f12bfc60e801bbcf.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/85087e27618d740c236bf159f30e0219db443ab55f0997388eed5fde6f9e90cc.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/88b07838348864aa86c672be3bbca1e9f58f6f3a2881b32070ec27f4e7b449d1.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/8b8cd408ccfbe115acef27ccfa5b233da8597131a2a5712add13e1e4d5d4504b.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/a23824fe746b9c6ca5eee9159b5764d1ff1653c1d856288c0f75c742bbb0023b.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/a3eb18af328280b139693c9092dff2a0ef8c9a967e6c8956ceee0996611f1984.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/bc1aacc65a102db325ca61bcd2f681e1ae22c36a1f1d98a6ff5e4ad49dc7544f.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/c682fd521747c19dae437d83ce3235a306ce6b68e24a117bc57c27ebb8d1f1ca.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/d5c224be7081f18cba1678b7874a9782eba895df004874ff8f243f94ba79942a.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f7f18bfb539b036a6a342176dd98a85df5057a884a8da978d679f2a0264883d0.json +0 -1
- xinference/ui/web/ui/node_modules/clipboard/.babelrc.json +0 -11
- xinference/ui/web/ui/node_modules/clipboard/.eslintrc.json +0 -24
- xinference/ui/web/ui/node_modules/clipboard/.prettierrc.json +0 -9
- xinference/ui/web/ui/node_modules/clipboard/bower.json +0 -18
- xinference/ui/web/ui/node_modules/clipboard/composer.json +0 -25
- xinference/ui/web/ui/node_modules/clipboard/package.json +0 -63
- xinference/ui/web/ui/node_modules/delegate/package.json +0 -31
- xinference/ui/web/ui/node_modules/good-listener/bower.json +0 -11
- xinference/ui/web/ui/node_modules/good-listener/package.json +0 -35
- xinference/ui/web/ui/node_modules/select/bower.json +0 -13
- xinference/ui/web/ui/node_modules/select/package.json +0 -29
- xinference/ui/web/ui/node_modules/tiny-emitter/package.json +0 -53
- {xinference-1.10.0.dist-info → xinference-1.10.1.dist-info}/WHEEL +0 -0
- {xinference-1.10.0.dist-info → xinference-1.10.1.dist-info}/entry_points.txt +0 -0
- {xinference-1.10.0.dist-info → xinference-1.10.1.dist-info}/licenses/LICENSE +0 -0
- {xinference-1.10.0.dist-info → xinference-1.10.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
import torch.utils.data
|
|
3
|
+
from librosa.filters import mel as librosa_mel_fn
|
|
4
|
+
|
|
5
|
+
MAX_WAV_VALUE = 32768.0
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def dynamic_range_compression_torch(x, C=1, clip_val=1e-5):
|
|
9
|
+
"""
|
|
10
|
+
PARAMS
|
|
11
|
+
------
|
|
12
|
+
C: compression factor
|
|
13
|
+
"""
|
|
14
|
+
return torch.log(torch.clamp(x, min=clip_val) * C)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def dynamic_range_decompression_torch(x, C=1):
|
|
18
|
+
"""
|
|
19
|
+
PARAMS
|
|
20
|
+
------
|
|
21
|
+
C: compression factor used to compress
|
|
22
|
+
"""
|
|
23
|
+
return torch.exp(x) / C
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def spectral_normalize_torch(magnitudes):
|
|
27
|
+
output = dynamic_range_compression_torch(magnitudes)
|
|
28
|
+
return output
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def spectral_de_normalize_torch(magnitudes):
|
|
32
|
+
output = dynamic_range_decompression_torch(magnitudes)
|
|
33
|
+
return output
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
mel_basis = {}
|
|
37
|
+
hann_window = {}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def spectrogram_torch(y, n_fft, sampling_rate, hop_size, win_size, center=False):
|
|
41
|
+
# if torch.min(y) < -1.1:
|
|
42
|
+
# print("min value is ", torch.min(y))
|
|
43
|
+
# if torch.max(y) > 1.1:
|
|
44
|
+
# print("max value is ", torch.max(y))
|
|
45
|
+
|
|
46
|
+
global hann_window
|
|
47
|
+
dtype_device = str(y.dtype) + "_" + str(y.device)
|
|
48
|
+
wnsize_dtype_device = str(win_size) + "_" + dtype_device
|
|
49
|
+
if wnsize_dtype_device not in hann_window:
|
|
50
|
+
hann_window[wnsize_dtype_device] = torch.hann_window(win_size).to(
|
|
51
|
+
dtype=y.dtype, device=y.device
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
y = torch.nn.functional.pad(
|
|
55
|
+
y.unsqueeze(1),
|
|
56
|
+
(int((n_fft - hop_size) / 2), int((n_fft - hop_size) / 2)),
|
|
57
|
+
mode="reflect",
|
|
58
|
+
)
|
|
59
|
+
y = y.squeeze(1)
|
|
60
|
+
|
|
61
|
+
spec = torch.stft(
|
|
62
|
+
y,
|
|
63
|
+
n_fft,
|
|
64
|
+
hop_length=hop_size,
|
|
65
|
+
win_length=win_size,
|
|
66
|
+
window=hann_window[wnsize_dtype_device],
|
|
67
|
+
center=center,
|
|
68
|
+
pad_mode="reflect",
|
|
69
|
+
normalized=False,
|
|
70
|
+
onesided=True,
|
|
71
|
+
return_complex=False,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
spec = torch.sqrt(spec.pow(2).sum(-1) + 1e-6)
|
|
75
|
+
return spec
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def spectrogram_torch_conv(y, n_fft, sampling_rate, hop_size, win_size, center=False):
|
|
79
|
+
# if torch.min(y) < -1.:
|
|
80
|
+
# print('min value is ', torch.min(y))
|
|
81
|
+
# if torch.max(y) > 1.:
|
|
82
|
+
# print('max value is ', torch.max(y))
|
|
83
|
+
|
|
84
|
+
global hann_window
|
|
85
|
+
dtype_device = str(y.dtype) + '_' + str(y.device)
|
|
86
|
+
wnsize_dtype_device = str(win_size) + '_' + dtype_device
|
|
87
|
+
if wnsize_dtype_device not in hann_window:
|
|
88
|
+
hann_window[wnsize_dtype_device] = torch.hann_window(win_size).to(dtype=y.dtype, device=y.device)
|
|
89
|
+
|
|
90
|
+
y = torch.nn.functional.pad(y.unsqueeze(1), (int((n_fft-hop_size)/2), int((n_fft-hop_size)/2)), mode='reflect')
|
|
91
|
+
|
|
92
|
+
# ******************** original ************************#
|
|
93
|
+
# y = y.squeeze(1)
|
|
94
|
+
# spec1 = torch.stft(y, n_fft, hop_length=hop_size, win_length=win_size, window=hann_window[wnsize_dtype_device],
|
|
95
|
+
# center=center, pad_mode='reflect', normalized=False, onesided=True, return_complex=False)
|
|
96
|
+
|
|
97
|
+
# ******************** ConvSTFT ************************#
|
|
98
|
+
freq_cutoff = n_fft // 2 + 1
|
|
99
|
+
fourier_basis = torch.view_as_real(torch.fft.fft(torch.eye(n_fft)))
|
|
100
|
+
forward_basis = fourier_basis[:freq_cutoff].permute(2, 0, 1).reshape(-1, 1, fourier_basis.shape[1])
|
|
101
|
+
forward_basis = forward_basis * torch.as_tensor(librosa.util.pad_center(torch.hann_window(win_size), size=n_fft)).float()
|
|
102
|
+
|
|
103
|
+
import torch.nn.functional as F
|
|
104
|
+
|
|
105
|
+
# if center:
|
|
106
|
+
# signal = F.pad(y[:, None, None, :], (n_fft // 2, n_fft // 2, 0, 0), mode = 'reflect').squeeze(1)
|
|
107
|
+
assert center is False
|
|
108
|
+
|
|
109
|
+
forward_transform_squared = F.conv1d(y, forward_basis.to(y.device), stride = hop_size)
|
|
110
|
+
spec2 = torch.stack([forward_transform_squared[:, :freq_cutoff, :], forward_transform_squared[:, freq_cutoff:, :]], dim = -1)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
# ******************** Verification ************************#
|
|
114
|
+
spec1 = torch.stft(y.squeeze(1), n_fft, hop_length=hop_size, win_length=win_size, window=hann_window[wnsize_dtype_device],
|
|
115
|
+
center=center, pad_mode='reflect', normalized=False, onesided=True, return_complex=False)
|
|
116
|
+
assert torch.allclose(spec1, spec2, atol=1e-4)
|
|
117
|
+
|
|
118
|
+
spec = torch.sqrt(spec2.pow(2).sum(-1) + 1e-6)
|
|
119
|
+
return spec
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def spec_to_mel_torch(spec, n_fft, num_mels, sampling_rate, fmin, fmax):
|
|
123
|
+
global mel_basis
|
|
124
|
+
dtype_device = str(spec.dtype) + "_" + str(spec.device)
|
|
125
|
+
fmax_dtype_device = str(fmax) + "_" + dtype_device
|
|
126
|
+
if fmax_dtype_device not in mel_basis:
|
|
127
|
+
mel = librosa_mel_fn(sampling_rate, n_fft, num_mels, fmin, fmax)
|
|
128
|
+
mel_basis[fmax_dtype_device] = torch.from_numpy(mel).to(
|
|
129
|
+
dtype=spec.dtype, device=spec.device
|
|
130
|
+
)
|
|
131
|
+
spec = torch.matmul(mel_basis[fmax_dtype_device], spec)
|
|
132
|
+
spec = spectral_normalize_torch(spec)
|
|
133
|
+
return spec
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def mel_spectrogram_torch(
|
|
137
|
+
y, n_fft, num_mels, sampling_rate, hop_size, win_size, fmin, fmax, center=False
|
|
138
|
+
):
|
|
139
|
+
if torch.min(y) < -1.0:
|
|
140
|
+
print("min value is ", torch.min(y))
|
|
141
|
+
if torch.max(y) > 1.0:
|
|
142
|
+
print("max value is ", torch.max(y))
|
|
143
|
+
|
|
144
|
+
global mel_basis, hann_window
|
|
145
|
+
dtype_device = str(y.dtype) + "_" + str(y.device)
|
|
146
|
+
fmax_dtype_device = str(fmax) + "_" + dtype_device
|
|
147
|
+
wnsize_dtype_device = str(win_size) + "_" + dtype_device
|
|
148
|
+
if fmax_dtype_device not in mel_basis:
|
|
149
|
+
mel = librosa_mel_fn(sampling_rate, n_fft, num_mels, fmin, fmax)
|
|
150
|
+
mel_basis[fmax_dtype_device] = torch.from_numpy(mel).to(
|
|
151
|
+
dtype=y.dtype, device=y.device
|
|
152
|
+
)
|
|
153
|
+
if wnsize_dtype_device not in hann_window:
|
|
154
|
+
hann_window[wnsize_dtype_device] = torch.hann_window(win_size).to(
|
|
155
|
+
dtype=y.dtype, device=y.device
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
y = torch.nn.functional.pad(
|
|
159
|
+
y.unsqueeze(1),
|
|
160
|
+
(int((n_fft - hop_size) / 2), int((n_fft - hop_size) / 2)),
|
|
161
|
+
mode="reflect",
|
|
162
|
+
)
|
|
163
|
+
y = y.squeeze(1)
|
|
164
|
+
|
|
165
|
+
spec = torch.stft(
|
|
166
|
+
y,
|
|
167
|
+
n_fft,
|
|
168
|
+
hop_length=hop_size,
|
|
169
|
+
win_length=win_size,
|
|
170
|
+
window=hann_window[wnsize_dtype_device],
|
|
171
|
+
center=center,
|
|
172
|
+
pad_mode="reflect",
|
|
173
|
+
normalized=False,
|
|
174
|
+
onesided=True,
|
|
175
|
+
return_complex=False,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
spec = torch.sqrt(spec.pow(2).sum(-1) + 1e-6)
|
|
179
|
+
|
|
180
|
+
spec = torch.matmul(mel_basis[fmax_dtype_device], spec)
|
|
181
|
+
spec = spectral_normalize_torch(spec)
|
|
182
|
+
|
|
183
|
+
return spec
|
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import torch
|
|
3
|
+
from torch import nn
|
|
4
|
+
from torch.nn import functional as F
|
|
5
|
+
|
|
6
|
+
from . import commons
|
|
7
|
+
from . import modules
|
|
8
|
+
from . import attentions
|
|
9
|
+
|
|
10
|
+
from torch.nn import Conv1d, ConvTranspose1d, Conv2d
|
|
11
|
+
from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm
|
|
12
|
+
|
|
13
|
+
from .commons import init_weights, get_padding
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class TextEncoder(nn.Module):
|
|
17
|
+
def __init__(self,
|
|
18
|
+
n_vocab,
|
|
19
|
+
out_channels,
|
|
20
|
+
hidden_channels,
|
|
21
|
+
filter_channels,
|
|
22
|
+
n_heads,
|
|
23
|
+
n_layers,
|
|
24
|
+
kernel_size,
|
|
25
|
+
p_dropout):
|
|
26
|
+
super().__init__()
|
|
27
|
+
self.n_vocab = n_vocab
|
|
28
|
+
self.out_channels = out_channels
|
|
29
|
+
self.hidden_channels = hidden_channels
|
|
30
|
+
self.filter_channels = filter_channels
|
|
31
|
+
self.n_heads = n_heads
|
|
32
|
+
self.n_layers = n_layers
|
|
33
|
+
self.kernel_size = kernel_size
|
|
34
|
+
self.p_dropout = p_dropout
|
|
35
|
+
|
|
36
|
+
self.emb = nn.Embedding(n_vocab, hidden_channels)
|
|
37
|
+
nn.init.normal_(self.emb.weight, 0.0, hidden_channels**-0.5)
|
|
38
|
+
|
|
39
|
+
self.encoder = attentions.Encoder(
|
|
40
|
+
hidden_channels,
|
|
41
|
+
filter_channels,
|
|
42
|
+
n_heads,
|
|
43
|
+
n_layers,
|
|
44
|
+
kernel_size,
|
|
45
|
+
p_dropout)
|
|
46
|
+
self.proj= nn.Conv1d(hidden_channels, out_channels * 2, 1)
|
|
47
|
+
|
|
48
|
+
def forward(self, x, x_lengths):
|
|
49
|
+
x = self.emb(x) * math.sqrt(self.hidden_channels) # [b, t, h]
|
|
50
|
+
x = torch.transpose(x, 1, -1) # [b, h, t]
|
|
51
|
+
x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(x.dtype)
|
|
52
|
+
|
|
53
|
+
x = self.encoder(x * x_mask, x_mask)
|
|
54
|
+
stats = self.proj(x) * x_mask
|
|
55
|
+
|
|
56
|
+
m, logs = torch.split(stats, self.out_channels, dim=1)
|
|
57
|
+
return x, m, logs, x_mask
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
class DurationPredictor(nn.Module):
|
|
61
|
+
def __init__(
|
|
62
|
+
self, in_channels, filter_channels, kernel_size, p_dropout, gin_channels=0
|
|
63
|
+
):
|
|
64
|
+
super().__init__()
|
|
65
|
+
|
|
66
|
+
self.in_channels = in_channels
|
|
67
|
+
self.filter_channels = filter_channels
|
|
68
|
+
self.kernel_size = kernel_size
|
|
69
|
+
self.p_dropout = p_dropout
|
|
70
|
+
self.gin_channels = gin_channels
|
|
71
|
+
|
|
72
|
+
self.drop = nn.Dropout(p_dropout)
|
|
73
|
+
self.conv_1 = nn.Conv1d(
|
|
74
|
+
in_channels, filter_channels, kernel_size, padding=kernel_size // 2
|
|
75
|
+
)
|
|
76
|
+
self.norm_1 = modules.LayerNorm(filter_channels)
|
|
77
|
+
self.conv_2 = nn.Conv1d(
|
|
78
|
+
filter_channels, filter_channels, kernel_size, padding=kernel_size // 2
|
|
79
|
+
)
|
|
80
|
+
self.norm_2 = modules.LayerNorm(filter_channels)
|
|
81
|
+
self.proj = nn.Conv1d(filter_channels, 1, 1)
|
|
82
|
+
|
|
83
|
+
if gin_channels != 0:
|
|
84
|
+
self.cond = nn.Conv1d(gin_channels, in_channels, 1)
|
|
85
|
+
|
|
86
|
+
def forward(self, x, x_mask, g=None):
|
|
87
|
+
x = torch.detach(x)
|
|
88
|
+
if g is not None:
|
|
89
|
+
g = torch.detach(g)
|
|
90
|
+
x = x + self.cond(g)
|
|
91
|
+
x = self.conv_1(x * x_mask)
|
|
92
|
+
x = torch.relu(x)
|
|
93
|
+
x = self.norm_1(x)
|
|
94
|
+
x = self.drop(x)
|
|
95
|
+
x = self.conv_2(x * x_mask)
|
|
96
|
+
x = torch.relu(x)
|
|
97
|
+
x = self.norm_2(x)
|
|
98
|
+
x = self.drop(x)
|
|
99
|
+
x = self.proj(x * x_mask)
|
|
100
|
+
return x * x_mask
|
|
101
|
+
|
|
102
|
+
class StochasticDurationPredictor(nn.Module):
|
|
103
|
+
def __init__(self, in_channels, filter_channels, kernel_size, p_dropout, n_flows=4, gin_channels=0):
|
|
104
|
+
super().__init__()
|
|
105
|
+
filter_channels = in_channels # it needs to be removed from future version.
|
|
106
|
+
self.in_channels = in_channels
|
|
107
|
+
self.filter_channels = filter_channels
|
|
108
|
+
self.kernel_size = kernel_size
|
|
109
|
+
self.p_dropout = p_dropout
|
|
110
|
+
self.n_flows = n_flows
|
|
111
|
+
self.gin_channels = gin_channels
|
|
112
|
+
|
|
113
|
+
self.log_flow = modules.Log()
|
|
114
|
+
self.flows = nn.ModuleList()
|
|
115
|
+
self.flows.append(modules.ElementwiseAffine(2))
|
|
116
|
+
for i in range(n_flows):
|
|
117
|
+
self.flows.append(modules.ConvFlow(2, filter_channels, kernel_size, n_layers=3))
|
|
118
|
+
self.flows.append(modules.Flip())
|
|
119
|
+
|
|
120
|
+
self.post_pre = nn.Conv1d(1, filter_channels, 1)
|
|
121
|
+
self.post_proj = nn.Conv1d(filter_channels, filter_channels, 1)
|
|
122
|
+
self.post_convs = modules.DDSConv(filter_channels, kernel_size, n_layers=3, p_dropout=p_dropout)
|
|
123
|
+
self.post_flows = nn.ModuleList()
|
|
124
|
+
self.post_flows.append(modules.ElementwiseAffine(2))
|
|
125
|
+
for i in range(4):
|
|
126
|
+
self.post_flows.append(modules.ConvFlow(2, filter_channels, kernel_size, n_layers=3))
|
|
127
|
+
self.post_flows.append(modules.Flip())
|
|
128
|
+
|
|
129
|
+
self.pre = nn.Conv1d(in_channels, filter_channels, 1)
|
|
130
|
+
self.proj = nn.Conv1d(filter_channels, filter_channels, 1)
|
|
131
|
+
self.convs = modules.DDSConv(filter_channels, kernel_size, n_layers=3, p_dropout=p_dropout)
|
|
132
|
+
if gin_channels != 0:
|
|
133
|
+
self.cond = nn.Conv1d(gin_channels, filter_channels, 1)
|
|
134
|
+
|
|
135
|
+
def forward(self, x, x_mask, w=None, g=None, reverse=False, noise_scale=1.0):
|
|
136
|
+
x = torch.detach(x)
|
|
137
|
+
x = self.pre(x)
|
|
138
|
+
if g is not None:
|
|
139
|
+
g = torch.detach(g)
|
|
140
|
+
x = x + self.cond(g)
|
|
141
|
+
x = self.convs(x, x_mask)
|
|
142
|
+
x = self.proj(x) * x_mask
|
|
143
|
+
|
|
144
|
+
if not reverse:
|
|
145
|
+
flows = self.flows
|
|
146
|
+
assert w is not None
|
|
147
|
+
|
|
148
|
+
logdet_tot_q = 0
|
|
149
|
+
h_w = self.post_pre(w)
|
|
150
|
+
h_w = self.post_convs(h_w, x_mask)
|
|
151
|
+
h_w = self.post_proj(h_w) * x_mask
|
|
152
|
+
e_q = torch.randn(w.size(0), 2, w.size(2)).to(device=x.device, dtype=x.dtype) * x_mask
|
|
153
|
+
z_q = e_q
|
|
154
|
+
for flow in self.post_flows:
|
|
155
|
+
z_q, logdet_q = flow(z_q, x_mask, g=(x + h_w))
|
|
156
|
+
logdet_tot_q += logdet_q
|
|
157
|
+
z_u, z1 = torch.split(z_q, [1, 1], 1)
|
|
158
|
+
u = torch.sigmoid(z_u) * x_mask
|
|
159
|
+
z0 = (w - u) * x_mask
|
|
160
|
+
logdet_tot_q += torch.sum((F.logsigmoid(z_u) + F.logsigmoid(-z_u)) * x_mask, [1,2])
|
|
161
|
+
logq = torch.sum(-0.5 * (math.log(2*math.pi) + (e_q**2)) * x_mask, [1,2]) - logdet_tot_q
|
|
162
|
+
|
|
163
|
+
logdet_tot = 0
|
|
164
|
+
z0, logdet = self.log_flow(z0, x_mask)
|
|
165
|
+
logdet_tot += logdet
|
|
166
|
+
z = torch.cat([z0, z1], 1)
|
|
167
|
+
for flow in flows:
|
|
168
|
+
z, logdet = flow(z, x_mask, g=x, reverse=reverse)
|
|
169
|
+
logdet_tot = logdet_tot + logdet
|
|
170
|
+
nll = torch.sum(0.5 * (math.log(2*math.pi) + (z**2)) * x_mask, [1,2]) - logdet_tot
|
|
171
|
+
return nll + logq # [b]
|
|
172
|
+
else:
|
|
173
|
+
flows = list(reversed(self.flows))
|
|
174
|
+
flows = flows[:-2] + [flows[-1]] # remove a useless vflow
|
|
175
|
+
z = torch.randn(x.size(0), 2, x.size(2)).to(device=x.device, dtype=x.dtype) * noise_scale
|
|
176
|
+
for flow in flows:
|
|
177
|
+
z = flow(z, x_mask, g=x, reverse=reverse)
|
|
178
|
+
z0, z1 = torch.split(z, [1, 1], 1)
|
|
179
|
+
logw = z0
|
|
180
|
+
return logw
|
|
181
|
+
|
|
182
|
+
class PosteriorEncoder(nn.Module):
|
|
183
|
+
def __init__(
|
|
184
|
+
self,
|
|
185
|
+
in_channels,
|
|
186
|
+
out_channels,
|
|
187
|
+
hidden_channels,
|
|
188
|
+
kernel_size,
|
|
189
|
+
dilation_rate,
|
|
190
|
+
n_layers,
|
|
191
|
+
gin_channels=0,
|
|
192
|
+
):
|
|
193
|
+
super().__init__()
|
|
194
|
+
self.in_channels = in_channels
|
|
195
|
+
self.out_channels = out_channels
|
|
196
|
+
self.hidden_channels = hidden_channels
|
|
197
|
+
self.kernel_size = kernel_size
|
|
198
|
+
self.dilation_rate = dilation_rate
|
|
199
|
+
self.n_layers = n_layers
|
|
200
|
+
self.gin_channels = gin_channels
|
|
201
|
+
|
|
202
|
+
self.pre = nn.Conv1d(in_channels, hidden_channels, 1)
|
|
203
|
+
self.enc = modules.WN(
|
|
204
|
+
hidden_channels,
|
|
205
|
+
kernel_size,
|
|
206
|
+
dilation_rate,
|
|
207
|
+
n_layers,
|
|
208
|
+
gin_channels=gin_channels,
|
|
209
|
+
)
|
|
210
|
+
self.proj = nn.Conv1d(hidden_channels, out_channels * 2, 1)
|
|
211
|
+
|
|
212
|
+
def forward(self, x, x_lengths, g=None, tau=1.0):
|
|
213
|
+
x_mask = torch.unsqueeze(commons.sequence_mask(x_lengths, x.size(2)), 1).to(
|
|
214
|
+
x.dtype
|
|
215
|
+
)
|
|
216
|
+
x = self.pre(x) * x_mask
|
|
217
|
+
x = self.enc(x, x_mask, g=g)
|
|
218
|
+
stats = self.proj(x) * x_mask
|
|
219
|
+
m, logs = torch.split(stats, self.out_channels, dim=1)
|
|
220
|
+
z = (m + torch.randn_like(m) * tau * torch.exp(logs)) * x_mask
|
|
221
|
+
return z, m, logs, x_mask
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
class Generator(torch.nn.Module):
|
|
225
|
+
def __init__(
|
|
226
|
+
self,
|
|
227
|
+
initial_channel,
|
|
228
|
+
resblock,
|
|
229
|
+
resblock_kernel_sizes,
|
|
230
|
+
resblock_dilation_sizes,
|
|
231
|
+
upsample_rates,
|
|
232
|
+
upsample_initial_channel,
|
|
233
|
+
upsample_kernel_sizes,
|
|
234
|
+
gin_channels=0,
|
|
235
|
+
):
|
|
236
|
+
super(Generator, self).__init__()
|
|
237
|
+
self.num_kernels = len(resblock_kernel_sizes)
|
|
238
|
+
self.num_upsamples = len(upsample_rates)
|
|
239
|
+
self.conv_pre = Conv1d(
|
|
240
|
+
initial_channel, upsample_initial_channel, 7, 1, padding=3
|
|
241
|
+
)
|
|
242
|
+
resblock = modules.ResBlock1 if resblock == "1" else modules.ResBlock2
|
|
243
|
+
|
|
244
|
+
self.ups = nn.ModuleList()
|
|
245
|
+
for i, (u, k) in enumerate(zip(upsample_rates, upsample_kernel_sizes)):
|
|
246
|
+
self.ups.append(
|
|
247
|
+
weight_norm(
|
|
248
|
+
ConvTranspose1d(
|
|
249
|
+
upsample_initial_channel // (2**i),
|
|
250
|
+
upsample_initial_channel // (2 ** (i + 1)),
|
|
251
|
+
k,
|
|
252
|
+
u,
|
|
253
|
+
padding=(k - u) // 2,
|
|
254
|
+
)
|
|
255
|
+
)
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
self.resblocks = nn.ModuleList()
|
|
259
|
+
for i in range(len(self.ups)):
|
|
260
|
+
ch = upsample_initial_channel // (2 ** (i + 1))
|
|
261
|
+
for j, (k, d) in enumerate(
|
|
262
|
+
zip(resblock_kernel_sizes, resblock_dilation_sizes)
|
|
263
|
+
):
|
|
264
|
+
self.resblocks.append(resblock(ch, k, d))
|
|
265
|
+
|
|
266
|
+
self.conv_post = Conv1d(ch, 1, 7, 1, padding=3, bias=False)
|
|
267
|
+
self.ups.apply(init_weights)
|
|
268
|
+
|
|
269
|
+
if gin_channels != 0:
|
|
270
|
+
self.cond = nn.Conv1d(gin_channels, upsample_initial_channel, 1)
|
|
271
|
+
|
|
272
|
+
def forward(self, x, g=None):
|
|
273
|
+
x = self.conv_pre(x)
|
|
274
|
+
if g is not None:
|
|
275
|
+
x = x + self.cond(g)
|
|
276
|
+
|
|
277
|
+
for i in range(self.num_upsamples):
|
|
278
|
+
x = F.leaky_relu(x, modules.LRELU_SLOPE)
|
|
279
|
+
x = self.ups[i](x)
|
|
280
|
+
xs = None
|
|
281
|
+
for j in range(self.num_kernels):
|
|
282
|
+
if xs is None:
|
|
283
|
+
xs = self.resblocks[i * self.num_kernels + j](x)
|
|
284
|
+
else:
|
|
285
|
+
xs += self.resblocks[i * self.num_kernels + j](x)
|
|
286
|
+
x = xs / self.num_kernels
|
|
287
|
+
x = F.leaky_relu(x)
|
|
288
|
+
x = self.conv_post(x)
|
|
289
|
+
x = torch.tanh(x)
|
|
290
|
+
|
|
291
|
+
return x
|
|
292
|
+
|
|
293
|
+
def remove_weight_norm(self):
|
|
294
|
+
print("Removing weight norm...")
|
|
295
|
+
for layer in self.ups:
|
|
296
|
+
remove_weight_norm(layer)
|
|
297
|
+
for layer in self.resblocks:
|
|
298
|
+
layer.remove_weight_norm()
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
class ReferenceEncoder(nn.Module):
|
|
302
|
+
"""
|
|
303
|
+
inputs --- [N, Ty/r, n_mels*r] mels
|
|
304
|
+
outputs --- [N, ref_enc_gru_size]
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
def __init__(self, spec_channels, gin_channels=0, layernorm=True):
|
|
308
|
+
super().__init__()
|
|
309
|
+
self.spec_channels = spec_channels
|
|
310
|
+
ref_enc_filters = [32, 32, 64, 64, 128, 128]
|
|
311
|
+
K = len(ref_enc_filters)
|
|
312
|
+
filters = [1] + ref_enc_filters
|
|
313
|
+
convs = [
|
|
314
|
+
weight_norm(
|
|
315
|
+
nn.Conv2d(
|
|
316
|
+
in_channels=filters[i],
|
|
317
|
+
out_channels=filters[i + 1],
|
|
318
|
+
kernel_size=(3, 3),
|
|
319
|
+
stride=(2, 2),
|
|
320
|
+
padding=(1, 1),
|
|
321
|
+
)
|
|
322
|
+
)
|
|
323
|
+
for i in range(K)
|
|
324
|
+
]
|
|
325
|
+
self.convs = nn.ModuleList(convs)
|
|
326
|
+
|
|
327
|
+
out_channels = self.calculate_channels(spec_channels, 3, 2, 1, K)
|
|
328
|
+
self.gru = nn.GRU(
|
|
329
|
+
input_size=ref_enc_filters[-1] * out_channels,
|
|
330
|
+
hidden_size=256 // 2,
|
|
331
|
+
batch_first=True,
|
|
332
|
+
)
|
|
333
|
+
self.proj = nn.Linear(128, gin_channels)
|
|
334
|
+
if layernorm:
|
|
335
|
+
self.layernorm = nn.LayerNorm(self.spec_channels)
|
|
336
|
+
else:
|
|
337
|
+
self.layernorm = None
|
|
338
|
+
|
|
339
|
+
def forward(self, inputs, mask=None):
|
|
340
|
+
N = inputs.size(0)
|
|
341
|
+
|
|
342
|
+
out = inputs.view(N, 1, -1, self.spec_channels) # [N, 1, Ty, n_freqs]
|
|
343
|
+
if self.layernorm is not None:
|
|
344
|
+
out = self.layernorm(out)
|
|
345
|
+
|
|
346
|
+
for conv in self.convs:
|
|
347
|
+
out = conv(out)
|
|
348
|
+
# out = wn(out)
|
|
349
|
+
out = F.relu(out) # [N, 128, Ty//2^K, n_mels//2^K]
|
|
350
|
+
|
|
351
|
+
out = out.transpose(1, 2) # [N, Ty//2^K, 128, n_mels//2^K]
|
|
352
|
+
T = out.size(1)
|
|
353
|
+
N = out.size(0)
|
|
354
|
+
out = out.contiguous().view(N, T, -1) # [N, Ty//2^K, 128*n_mels//2^K]
|
|
355
|
+
|
|
356
|
+
self.gru.flatten_parameters()
|
|
357
|
+
memory, out = self.gru(out) # out --- [1, N, 128]
|
|
358
|
+
|
|
359
|
+
return self.proj(out.squeeze(0))
|
|
360
|
+
|
|
361
|
+
def calculate_channels(self, L, kernel_size, stride, pad, n_convs):
|
|
362
|
+
for i in range(n_convs):
|
|
363
|
+
L = (L - kernel_size + 2 * pad) // stride + 1
|
|
364
|
+
return L
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
class ResidualCouplingBlock(nn.Module):
|
|
368
|
+
def __init__(self,
|
|
369
|
+
channels,
|
|
370
|
+
hidden_channels,
|
|
371
|
+
kernel_size,
|
|
372
|
+
dilation_rate,
|
|
373
|
+
n_layers,
|
|
374
|
+
n_flows=4,
|
|
375
|
+
gin_channels=0):
|
|
376
|
+
super().__init__()
|
|
377
|
+
self.channels = channels
|
|
378
|
+
self.hidden_channels = hidden_channels
|
|
379
|
+
self.kernel_size = kernel_size
|
|
380
|
+
self.dilation_rate = dilation_rate
|
|
381
|
+
self.n_layers = n_layers
|
|
382
|
+
self.n_flows = n_flows
|
|
383
|
+
self.gin_channels = gin_channels
|
|
384
|
+
|
|
385
|
+
self.flows = nn.ModuleList()
|
|
386
|
+
for i in range(n_flows):
|
|
387
|
+
self.flows.append(modules.ResidualCouplingLayer(channels, hidden_channels, kernel_size, dilation_rate, n_layers, gin_channels=gin_channels, mean_only=True))
|
|
388
|
+
self.flows.append(modules.Flip())
|
|
389
|
+
|
|
390
|
+
def forward(self, x, x_mask, g=None, reverse=False):
|
|
391
|
+
if not reverse:
|
|
392
|
+
for flow in self.flows:
|
|
393
|
+
x, _ = flow(x, x_mask, g=g, reverse=reverse)
|
|
394
|
+
else:
|
|
395
|
+
for flow in reversed(self.flows):
|
|
396
|
+
x = flow(x, x_mask, g=g, reverse=reverse)
|
|
397
|
+
return x
|
|
398
|
+
|
|
399
|
+
class SynthesizerTrn(nn.Module):
|
|
400
|
+
"""
|
|
401
|
+
Synthesizer for Training
|
|
402
|
+
"""
|
|
403
|
+
|
|
404
|
+
def __init__(
|
|
405
|
+
self,
|
|
406
|
+
n_vocab,
|
|
407
|
+
spec_channels,
|
|
408
|
+
inter_channels,
|
|
409
|
+
hidden_channels,
|
|
410
|
+
filter_channels,
|
|
411
|
+
n_heads,
|
|
412
|
+
n_layers,
|
|
413
|
+
kernel_size,
|
|
414
|
+
p_dropout,
|
|
415
|
+
resblock,
|
|
416
|
+
resblock_kernel_sizes,
|
|
417
|
+
resblock_dilation_sizes,
|
|
418
|
+
upsample_rates,
|
|
419
|
+
upsample_initial_channel,
|
|
420
|
+
upsample_kernel_sizes,
|
|
421
|
+
n_speakers=256,
|
|
422
|
+
gin_channels=256,
|
|
423
|
+
zero_g=False,
|
|
424
|
+
**kwargs
|
|
425
|
+
):
|
|
426
|
+
super().__init__()
|
|
427
|
+
|
|
428
|
+
self.dec = Generator(
|
|
429
|
+
inter_channels,
|
|
430
|
+
resblock,
|
|
431
|
+
resblock_kernel_sizes,
|
|
432
|
+
resblock_dilation_sizes,
|
|
433
|
+
upsample_rates,
|
|
434
|
+
upsample_initial_channel,
|
|
435
|
+
upsample_kernel_sizes,
|
|
436
|
+
gin_channels=gin_channels,
|
|
437
|
+
)
|
|
438
|
+
self.enc_q = PosteriorEncoder(
|
|
439
|
+
spec_channels,
|
|
440
|
+
inter_channels,
|
|
441
|
+
hidden_channels,
|
|
442
|
+
5,
|
|
443
|
+
1,
|
|
444
|
+
16,
|
|
445
|
+
gin_channels=gin_channels,
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
self.flow = ResidualCouplingBlock(inter_channels, hidden_channels, 5, 1, 4, gin_channels=gin_channels)
|
|
449
|
+
|
|
450
|
+
self.n_speakers = n_speakers
|
|
451
|
+
if n_speakers == 0:
|
|
452
|
+
self.ref_enc = ReferenceEncoder(spec_channels, gin_channels)
|
|
453
|
+
else:
|
|
454
|
+
self.enc_p = TextEncoder(n_vocab,
|
|
455
|
+
inter_channels,
|
|
456
|
+
hidden_channels,
|
|
457
|
+
filter_channels,
|
|
458
|
+
n_heads,
|
|
459
|
+
n_layers,
|
|
460
|
+
kernel_size,
|
|
461
|
+
p_dropout)
|
|
462
|
+
self.sdp = StochasticDurationPredictor(hidden_channels, 192, 3, 0.5, 4, gin_channels=gin_channels)
|
|
463
|
+
self.dp = DurationPredictor(hidden_channels, 256, 3, 0.5, gin_channels=gin_channels)
|
|
464
|
+
self.emb_g = nn.Embedding(n_speakers, gin_channels)
|
|
465
|
+
self.zero_g = zero_g
|
|
466
|
+
|
|
467
|
+
def infer(self, x, x_lengths, sid=None, noise_scale=1, length_scale=1, noise_scale_w=1., sdp_ratio=0.2, max_len=None):
|
|
468
|
+
x, m_p, logs_p, x_mask = self.enc_p(x, x_lengths)
|
|
469
|
+
if self.n_speakers > 0:
|
|
470
|
+
g = self.emb_g(sid).unsqueeze(-1) # [b, h, 1]
|
|
471
|
+
else:
|
|
472
|
+
g = None
|
|
473
|
+
|
|
474
|
+
logw = self.sdp(x, x_mask, g=g, reverse=True, noise_scale=noise_scale_w) * sdp_ratio \
|
|
475
|
+
+ self.dp(x, x_mask, g=g) * (1 - sdp_ratio)
|
|
476
|
+
|
|
477
|
+
w = torch.exp(logw) * x_mask * length_scale
|
|
478
|
+
w_ceil = torch.ceil(w)
|
|
479
|
+
y_lengths = torch.clamp_min(torch.sum(w_ceil, [1, 2]), 1).long()
|
|
480
|
+
y_mask = torch.unsqueeze(commons.sequence_mask(y_lengths, None), 1).to(x_mask.dtype)
|
|
481
|
+
attn_mask = torch.unsqueeze(x_mask, 2) * torch.unsqueeze(y_mask, -1)
|
|
482
|
+
attn = commons.generate_path(w_ceil, attn_mask)
|
|
483
|
+
|
|
484
|
+
m_p = torch.matmul(attn.squeeze(1), m_p.transpose(1, 2)).transpose(1, 2) # [b, t', t], [b, t, d] -> [b, d, t']
|
|
485
|
+
logs_p = torch.matmul(attn.squeeze(1), logs_p.transpose(1, 2)).transpose(1, 2) # [b, t', t], [b, t, d] -> [b, d, t']
|
|
486
|
+
|
|
487
|
+
z_p = m_p + torch.randn_like(m_p) * torch.exp(logs_p) * noise_scale
|
|
488
|
+
z = self.flow(z_p, y_mask, g=g, reverse=True)
|
|
489
|
+
o = self.dec((z * y_mask)[:,:,:max_len], g=g)
|
|
490
|
+
return o, attn, y_mask, (z, z_p, m_p, logs_p)
|
|
491
|
+
|
|
492
|
+
def voice_conversion(self, y, y_lengths, sid_src, sid_tgt, tau=1.0):
|
|
493
|
+
g_src = sid_src
|
|
494
|
+
g_tgt = sid_tgt
|
|
495
|
+
z, m_q, logs_q, y_mask = self.enc_q(y, y_lengths, g=g_src if not self.zero_g else torch.zeros_like(g_src), tau=tau)
|
|
496
|
+
z_p = self.flow(z, y_mask, g=g_src)
|
|
497
|
+
z_hat = self.flow(z_p, y_mask, g=g_tgt, reverse=True)
|
|
498
|
+
o_hat = self.dec(z_hat * y_mask, g=g_tgt if not self.zero_g else torch.zeros_like(g_tgt))
|
|
499
|
+
return o_hat, y_mask, (z, z_p, z_hat)
|