xinference 1.0.1__py3-none-any.whl → 1.2.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/_compat.py +2 -0
- xinference/_version.py +3 -3
- xinference/api/restful_api.py +77 -71
- xinference/core/chat_interface.py +6 -1
- xinference/core/model.py +79 -19
- xinference/core/supervisor.py +172 -10
- xinference/core/utils.py +12 -8
- xinference/core/worker.py +102 -4
- xinference/deploy/cmdline.py +3 -1
- xinference/deploy/test/test_cmdline.py +56 -0
- xinference/isolation.py +24 -0
- xinference/model/audio/core.py +16 -0
- xinference/model/audio/cosyvoice.py +39 -6
- xinference/model/audio/f5tts.py +200 -0
- xinference/model/audio/f5tts_mlx.py +260 -0
- xinference/model/audio/fish_speech.py +36 -111
- xinference/model/audio/melotts.py +110 -0
- xinference/model/audio/model_spec.json +99 -3
- xinference/model/audio/model_spec_modelscope.json +27 -0
- xinference/model/audio/utils.py +32 -0
- xinference/model/audio/whisper.py +35 -10
- xinference/model/embedding/core.py +203 -142
- xinference/model/embedding/model_spec.json +7 -0
- xinference/model/embedding/model_spec_modelscope.json +8 -0
- xinference/model/image/core.py +69 -1
- xinference/model/image/model_spec.json +145 -4
- xinference/model/image/model_spec_modelscope.json +150 -4
- xinference/model/image/stable_diffusion/core.py +45 -13
- xinference/model/llm/__init__.py +4 -2
- xinference/model/llm/llm_family.json +536 -53
- xinference/model/llm/llm_family.py +15 -36
- xinference/model/llm/llm_family_modelscope.json +454 -20
- xinference/model/llm/memory.py +1 -1
- xinference/model/llm/mlx/core.py +248 -52
- xinference/model/llm/sglang/core.py +1 -0
- xinference/model/llm/transformers/chatglm.py +9 -5
- xinference/model/llm/transformers/cogagent.py +272 -0
- xinference/model/llm/transformers/core.py +2 -0
- xinference/model/llm/transformers/qwen2_vl.py +12 -1
- xinference/model/llm/transformers/utils.py +16 -8
- xinference/model/llm/utils.py +36 -4
- xinference/model/llm/vllm/core.py +53 -10
- xinference/model/llm/vllm/xavier/__init__.py +13 -0
- xinference/model/llm/vllm/xavier/allocator.py +74 -0
- xinference/model/llm/vllm/xavier/block.py +111 -0
- xinference/model/llm/vllm/xavier/block_manager.py +71 -0
- xinference/model/llm/vllm/xavier/block_tracker.py +129 -0
- xinference/model/llm/vllm/xavier/collective.py +74 -0
- xinference/model/llm/vllm/xavier/collective_manager.py +147 -0
- xinference/model/llm/vllm/xavier/engine.py +247 -0
- xinference/model/llm/vllm/xavier/executor.py +134 -0
- xinference/model/llm/vllm/xavier/scheduler.py +438 -0
- xinference/model/llm/vllm/xavier/test/__init__.py +13 -0
- xinference/model/llm/vllm/xavier/test/test_xavier.py +147 -0
- xinference/model/llm/vllm/xavier/transfer.py +319 -0
- xinference/model/video/diffusers.py +14 -0
- xinference/model/video/model_spec.json +15 -0
- xinference/model/video/model_spec_modelscope.json +16 -0
- xinference/thirdparty/cosyvoice/bin/average_model.py +92 -0
- xinference/thirdparty/cosyvoice/bin/export_jit.py +12 -2
- xinference/thirdparty/cosyvoice/bin/export_onnx.py +112 -0
- xinference/thirdparty/cosyvoice/bin/export_trt.sh +9 -0
- xinference/thirdparty/cosyvoice/bin/inference.py +5 -7
- xinference/thirdparty/cosyvoice/bin/spk2info.pt +0 -0
- xinference/thirdparty/cosyvoice/bin/train.py +42 -8
- xinference/thirdparty/cosyvoice/cli/cosyvoice.py +96 -25
- xinference/thirdparty/cosyvoice/cli/frontend.py +77 -30
- xinference/thirdparty/cosyvoice/cli/model.py +330 -80
- xinference/thirdparty/cosyvoice/dataset/dataset.py +6 -2
- xinference/thirdparty/cosyvoice/dataset/processor.py +76 -14
- xinference/thirdparty/cosyvoice/flow/decoder.py +92 -13
- xinference/thirdparty/cosyvoice/flow/flow.py +99 -9
- xinference/thirdparty/cosyvoice/flow/flow_matching.py +110 -13
- xinference/thirdparty/cosyvoice/flow/length_regulator.py +5 -4
- xinference/thirdparty/cosyvoice/hifigan/discriminator.py +140 -0
- xinference/thirdparty/cosyvoice/hifigan/generator.py +58 -42
- xinference/thirdparty/cosyvoice/hifigan/hifigan.py +67 -0
- xinference/thirdparty/cosyvoice/llm/llm.py +139 -6
- xinference/thirdparty/cosyvoice/tokenizer/assets/multilingual_zh_ja_yue_char_del.tiktoken +58836 -0
- xinference/thirdparty/cosyvoice/tokenizer/tokenizer.py +279 -0
- xinference/thirdparty/cosyvoice/transformer/embedding.py +2 -2
- xinference/thirdparty/cosyvoice/transformer/encoder_layer.py +7 -7
- xinference/thirdparty/cosyvoice/transformer/upsample_encoder.py +318 -0
- xinference/thirdparty/cosyvoice/utils/common.py +28 -1
- xinference/thirdparty/cosyvoice/utils/executor.py +69 -7
- xinference/thirdparty/cosyvoice/utils/file_utils.py +2 -12
- xinference/thirdparty/cosyvoice/utils/frontend_utils.py +9 -5
- xinference/thirdparty/cosyvoice/utils/losses.py +20 -0
- xinference/thirdparty/cosyvoice/utils/scheduler.py +1 -2
- xinference/thirdparty/cosyvoice/utils/train_utils.py +101 -45
- xinference/thirdparty/f5_tts/api.py +166 -0
- xinference/thirdparty/f5_tts/configs/E2TTS_Base_train.yaml +44 -0
- xinference/thirdparty/f5_tts/configs/E2TTS_Small_train.yaml +44 -0
- xinference/thirdparty/f5_tts/configs/F5TTS_Base_train.yaml +46 -0
- xinference/thirdparty/f5_tts/configs/F5TTS_Small_train.yaml +46 -0
- xinference/thirdparty/f5_tts/eval/README.md +49 -0
- xinference/thirdparty/f5_tts/eval/ecapa_tdnn.py +330 -0
- xinference/thirdparty/f5_tts/eval/eval_infer_batch.py +207 -0
- xinference/thirdparty/f5_tts/eval/eval_infer_batch.sh +13 -0
- xinference/thirdparty/f5_tts/eval/eval_librispeech_test_clean.py +84 -0
- xinference/thirdparty/f5_tts/eval/eval_seedtts_testset.py +84 -0
- xinference/thirdparty/f5_tts/eval/utils_eval.py +405 -0
- xinference/thirdparty/f5_tts/infer/README.md +191 -0
- xinference/thirdparty/f5_tts/infer/SHARED.md +74 -0
- xinference/thirdparty/f5_tts/infer/examples/basic/basic.toml +11 -0
- xinference/thirdparty/f5_tts/infer/examples/basic/basic_ref_en.wav +0 -0
- xinference/thirdparty/f5_tts/infer/examples/basic/basic_ref_zh.wav +0 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/country.flac +0 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/main.flac +0 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/story.toml +19 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/story.txt +1 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/town.flac +0 -0
- xinference/thirdparty/f5_tts/infer/examples/vocab.txt +2545 -0
- xinference/thirdparty/f5_tts/infer/infer_cli.py +226 -0
- xinference/thirdparty/f5_tts/infer/infer_gradio.py +851 -0
- xinference/thirdparty/f5_tts/infer/speech_edit.py +193 -0
- xinference/thirdparty/f5_tts/infer/utils_infer.py +538 -0
- xinference/thirdparty/f5_tts/model/__init__.py +10 -0
- xinference/thirdparty/f5_tts/model/backbones/README.md +20 -0
- xinference/thirdparty/f5_tts/model/backbones/dit.py +163 -0
- xinference/thirdparty/f5_tts/model/backbones/mmdit.py +146 -0
- xinference/thirdparty/f5_tts/model/backbones/unett.py +219 -0
- xinference/thirdparty/f5_tts/model/cfm.py +285 -0
- xinference/thirdparty/f5_tts/model/dataset.py +319 -0
- xinference/thirdparty/f5_tts/model/modules.py +658 -0
- xinference/thirdparty/f5_tts/model/trainer.py +366 -0
- xinference/thirdparty/f5_tts/model/utils.py +185 -0
- xinference/thirdparty/f5_tts/scripts/count_max_epoch.py +33 -0
- xinference/thirdparty/f5_tts/scripts/count_params_gflops.py +39 -0
- xinference/thirdparty/f5_tts/socket_server.py +159 -0
- xinference/thirdparty/f5_tts/train/README.md +77 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_csv_wavs.py +139 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_emilia.py +230 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_libritts.py +92 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_ljspeech.py +65 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_wenetspeech4tts.py +125 -0
- xinference/thirdparty/f5_tts/train/finetune_cli.py +174 -0
- xinference/thirdparty/f5_tts/train/finetune_gradio.py +1846 -0
- xinference/thirdparty/f5_tts/train/train.py +75 -0
- xinference/thirdparty/fish_speech/fish_speech/conversation.py +94 -83
- xinference/thirdparty/fish_speech/fish_speech/models/text2semantic/llama.py +63 -20
- xinference/thirdparty/fish_speech/fish_speech/text/clean.py +1 -26
- xinference/thirdparty/fish_speech/fish_speech/text/spliter.py +1 -1
- xinference/thirdparty/fish_speech/fish_speech/tokenizer.py +152 -0
- xinference/thirdparty/fish_speech/fish_speech/train.py +2 -2
- xinference/thirdparty/fish_speech/fish_speech/webui/manage.py +1 -1
- xinference/thirdparty/fish_speech/tools/{post_api.py → api_client.py} +7 -13
- xinference/thirdparty/fish_speech/tools/api_server.py +98 -0
- xinference/thirdparty/fish_speech/tools/download_models.py +5 -5
- xinference/thirdparty/fish_speech/tools/fish_e2e.py +2 -2
- xinference/thirdparty/fish_speech/tools/inference_engine/__init__.py +192 -0
- xinference/thirdparty/fish_speech/tools/inference_engine/reference_loader.py +125 -0
- xinference/thirdparty/fish_speech/tools/inference_engine/utils.py +39 -0
- xinference/thirdparty/fish_speech/tools/inference_engine/vq_manager.py +57 -0
- xinference/thirdparty/fish_speech/tools/llama/eval_in_context.py +2 -2
- xinference/thirdparty/fish_speech/tools/llama/generate.py +117 -89
- xinference/thirdparty/fish_speech/tools/run_webui.py +104 -0
- xinference/thirdparty/fish_speech/tools/schema.py +11 -28
- xinference/thirdparty/fish_speech/tools/server/agent/__init__.py +57 -0
- xinference/thirdparty/fish_speech/tools/server/agent/generate.py +119 -0
- xinference/thirdparty/fish_speech/tools/server/agent/generation_utils.py +122 -0
- xinference/thirdparty/fish_speech/tools/server/agent/pre_generation_utils.py +72 -0
- xinference/thirdparty/fish_speech/tools/server/api_utils.py +75 -0
- xinference/thirdparty/fish_speech/tools/server/exception_handler.py +27 -0
- xinference/thirdparty/fish_speech/tools/server/inference.py +45 -0
- xinference/thirdparty/fish_speech/tools/server/model_manager.py +122 -0
- xinference/thirdparty/fish_speech/tools/server/model_utils.py +129 -0
- xinference/thirdparty/fish_speech/tools/server/views.py +246 -0
- xinference/thirdparty/fish_speech/tools/webui/__init__.py +173 -0
- xinference/thirdparty/fish_speech/tools/webui/inference.py +91 -0
- xinference/thirdparty/fish_speech/tools/webui/variables.py +14 -0
- xinference/thirdparty/matcha/utils/utils.py +2 -2
- xinference/thirdparty/melo/api.py +135 -0
- xinference/thirdparty/melo/app.py +61 -0
- xinference/thirdparty/melo/attentions.py +459 -0
- xinference/thirdparty/melo/commons.py +160 -0
- xinference/thirdparty/melo/configs/config.json +94 -0
- xinference/thirdparty/melo/data/example/metadata.list +20 -0
- xinference/thirdparty/melo/data_utils.py +413 -0
- xinference/thirdparty/melo/download_utils.py +67 -0
- xinference/thirdparty/melo/infer.py +25 -0
- xinference/thirdparty/melo/init_downloads.py +14 -0
- xinference/thirdparty/melo/losses.py +58 -0
- xinference/thirdparty/melo/main.py +36 -0
- xinference/thirdparty/melo/mel_processing.py +174 -0
- xinference/thirdparty/melo/models.py +1030 -0
- xinference/thirdparty/melo/modules.py +598 -0
- xinference/thirdparty/melo/monotonic_align/__init__.py +16 -0
- xinference/thirdparty/melo/monotonic_align/core.py +46 -0
- xinference/thirdparty/melo/preprocess_text.py +135 -0
- xinference/thirdparty/melo/split_utils.py +174 -0
- xinference/thirdparty/melo/text/__init__.py +35 -0
- xinference/thirdparty/melo/text/chinese.py +199 -0
- xinference/thirdparty/melo/text/chinese_bert.py +107 -0
- xinference/thirdparty/melo/text/chinese_mix.py +253 -0
- xinference/thirdparty/melo/text/cleaner.py +36 -0
- xinference/thirdparty/melo/text/cleaner_multiling.py +110 -0
- xinference/thirdparty/melo/text/cmudict.rep +129530 -0
- xinference/thirdparty/melo/text/cmudict_cache.pickle +0 -0
- xinference/thirdparty/melo/text/english.py +284 -0
- xinference/thirdparty/melo/text/english_bert.py +39 -0
- xinference/thirdparty/melo/text/english_utils/abbreviations.py +35 -0
- xinference/thirdparty/melo/text/english_utils/number_norm.py +97 -0
- xinference/thirdparty/melo/text/english_utils/time_norm.py +47 -0
- xinference/thirdparty/melo/text/es_phonemizer/base.py +140 -0
- xinference/thirdparty/melo/text/es_phonemizer/cleaner.py +109 -0
- xinference/thirdparty/melo/text/es_phonemizer/es_symbols.json +79 -0
- xinference/thirdparty/melo/text/es_phonemizer/es_symbols.txt +1 -0
- xinference/thirdparty/melo/text/es_phonemizer/es_symbols_v2.json +83 -0
- xinference/thirdparty/melo/text/es_phonemizer/es_to_ipa.py +12 -0
- xinference/thirdparty/melo/text/es_phonemizer/example_ipa.txt +400 -0
- xinference/thirdparty/melo/text/es_phonemizer/gruut_wrapper.py +253 -0
- xinference/thirdparty/melo/text/es_phonemizer/punctuation.py +174 -0
- xinference/thirdparty/melo/text/es_phonemizer/spanish_symbols.txt +1 -0
- xinference/thirdparty/melo/text/es_phonemizer/test.ipynb +124 -0
- xinference/thirdparty/melo/text/fr_phonemizer/base.py +140 -0
- xinference/thirdparty/melo/text/fr_phonemizer/cleaner.py +122 -0
- xinference/thirdparty/melo/text/fr_phonemizer/en_symbols.json +78 -0
- xinference/thirdparty/melo/text/fr_phonemizer/example_ipa.txt +1 -0
- xinference/thirdparty/melo/text/fr_phonemizer/fr_symbols.json +89 -0
- xinference/thirdparty/melo/text/fr_phonemizer/fr_to_ipa.py +30 -0
- xinference/thirdparty/melo/text/fr_phonemizer/french_abbreviations.py +48 -0
- xinference/thirdparty/melo/text/fr_phonemizer/french_symbols.txt +1 -0
- xinference/thirdparty/melo/text/fr_phonemizer/gruut_wrapper.py +258 -0
- xinference/thirdparty/melo/text/fr_phonemizer/punctuation.py +172 -0
- xinference/thirdparty/melo/text/french.py +94 -0
- xinference/thirdparty/melo/text/french_bert.py +39 -0
- xinference/thirdparty/melo/text/japanese.py +647 -0
- xinference/thirdparty/melo/text/japanese_bert.py +49 -0
- xinference/thirdparty/melo/text/ko_dictionary.py +44 -0
- xinference/thirdparty/melo/text/korean.py +192 -0
- xinference/thirdparty/melo/text/opencpop-strict.txt +429 -0
- xinference/thirdparty/melo/text/spanish.py +122 -0
- xinference/thirdparty/melo/text/spanish_bert.py +39 -0
- xinference/thirdparty/melo/text/symbols.py +290 -0
- xinference/thirdparty/melo/text/tone_sandhi.py +769 -0
- xinference/thirdparty/melo/train.py +635 -0
- xinference/thirdparty/melo/train.sh +19 -0
- xinference/thirdparty/melo/transforms.py +209 -0
- xinference/thirdparty/melo/utils.py +424 -0
- xinference/types.py +15 -0
- xinference/web/ui/build/asset-manifest.json +6 -6
- xinference/web/ui/build/index.html +1 -1
- xinference/web/ui/build/static/css/main.51a587ff.css +2 -0
- xinference/web/ui/build/static/css/main.51a587ff.css.map +1 -0
- xinference/web/ui/build/static/js/main.b0936c54.js +3 -0
- xinference/web/ui/build/static/js/main.b0936c54.js.map +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/03c4052f1b91f6ba0c5389bdcf49c43319b4076c08e4b8585dab312538ae290a.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/1786b83003b8e9605a0f5f855a185d4d16e38fc893dfb326a2a9cca206b4240a.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/17cbc181dd674b9150b80c73ed6a82656de0082d857f6e5f66d9716129ac0b38.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/185ceb8872d562e032b47e79df6a45670e06345b8ed70aad1a131e0476783c5c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/26b8c9f34b0bed789b3a833767672e39302d1e0c09b4276f4d58d1df7b6bd93b.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/2b484da66c724d0d56a40849c109327408796a668b1381511b6e9e03baa48658.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/2cbbbce9b84df73330d4c42b82436ed881b3847628f2fbc346aa62e2859fd88c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/2ec9b14431ed33ce6901bf9f27007be4e6e472709c99d6e22b50ce528e4b78ee.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/3b966db018f96be4a055d6ca205f0990d4d0b370e2980c17d8bca2c9a021819c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/3eefb411b24c2b3ce053570ef50daccf154022f0e168be5ed0fec21394baf9f4.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/522b229e3cac219123f0d69673f5570e191c2d2a505dc65b312d336eae2279c0.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/52e45f17ba300580ea3fcc9f9228ccba194bb092b76f25e9255af311f8b05aab.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/5a0bc4631f936459afc1a3b1d3ec2420118b1f00e11f60ccac3e08088f3f27a8.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/611fa2c6c53b66039991d06dfb0473b5ab37fc63b4564e0f6e1718523768a045.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/6329bc76c406fe5eb305412383fbde5950f847bb5e43261f73f37622c365acb4.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/63c8e07687ea53a4f8a910ee5e42e0eb26cd1acbfbe820f3e3248a786ee51401.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/69b2d5001684174ec9da57e07914eed3eac4960018bceb6cbfa801d861301d7c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/710c1acda69e561e30a933b98c6a56d50197868b15c21e2aad55ab6d46649eb6.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/720deca1fce5a1dc5056048fa8258fd138a82ea855f350b6613f104a73fb761f.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/76a23b92d26a499c57e61eea2b895fbc9771bd0849a72e66f8e633192017978b.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/858063f23b34dfe600254eb5afd85518b0002ec4b30b7386616c45600826e3b2.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/920b82c1c89124cf217109eeedbfcd3aae3b917be50c9dfb6bbb4ce26bdfd2e7.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/94d8b7aeb0076f2ce07db598cea0e87b13bc8d5614eb530b8d6e696c2daf6f88.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/9e917fe7022d01b2ccbe5cc0ce73d70bb72bee584ff293bad71bdff6695dee28.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/9f28fdb8399f1d0474f0aca86f1658dc94f5bf0c90f6146352de150692de8862.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/a0dfafa06b2bb7cba8cad41c482503f61944f759f4318139362602ef5cc47ccb.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/a3ff866acddf34917a7ee399e0e571a4dfd8ba66d5057db885f243e16a6eb17d.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/afb8084f539534cd594755ea2205ecd5bd1f62dddcfdf75a2eace59a28131278.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/b57b1438b77294c1f3f6cfce12ac487d8106c6f016975ba0aec94d98997e2e1e.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/b9917b0bf8e4d55ccbac1c334aa04d6ff3c5b6ed9e5d38b9ea2c687fa7d3f5a9.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/bbcc94b0149963d1d6f267ee1f4f03d3925b758392ce2f516c3fe8af0e0169fc.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/bdee44abeadc4abc17d41c52eb49c6e19a4b1a267b6e16876ce91bdeeebfc52d.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/beb112b70f4a56db95920a9e20efb6c97c37b68450716730217a9ee1a9ae92be.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/c88db97be0cdf440193b3995996e83510a04cb00048135485fc0e26d197e80b5.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/d49e5314d34310a62d01a03067ce1bec5da00abce84c5196aa9c6842fa79a430.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/d7664d18c4ddbad9c3a6a31b91f7c00fb0dde804608674a9860ee50f33e54708.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/d9072c318b819b7c90a0f7e9cc0b6413b4dbeb8e9859898e53d75ea882fcde99.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/db16a983bc08a05f0439cc61ca0840e49e1d8400eef678909f16c032a418a3d6.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/dc249829767b8abcbc3677e0b07b6d3ecbfdfe6d08cfe23a665eb33373a9aa9d.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/e242c583c2dbc2784f0fcf513523975f7d5df447e106c1c17e49e8578a6fc3ed.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/eac5f1296513e69e4b96f750ddccd4d0264e2bae4e4c449144e83274a48698d9.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/ed57202cb79649bb716400436590245547df241988fc7c8e1d85d132299542d2.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/f125bf72e773a14cdaebd0c343e80adb909d12e317ee5c00cd4a57442fbe2c62.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/f91af913d7f91c410719ab13136aaed3aaf0f8dda06652f25c42cb5231587398.json +1 -0
- xinference/web/ui/node_modules/.package-lock.json +67 -3
- xinference/web/ui/node_modules/@babel/runtime/package.json +592 -538
- xinference/web/ui/node_modules/html-parse-stringify/package.json +50 -0
- xinference/web/ui/node_modules/i18next/dist/esm/package.json +1 -0
- xinference/web/ui/node_modules/i18next/package.json +129 -0
- xinference/web/ui/node_modules/react-i18next/.eslintrc.json +74 -0
- xinference/web/ui/node_modules/react-i18next/dist/es/package.json +1 -0
- xinference/web/ui/node_modules/react-i18next/package.json +162 -0
- xinference/web/ui/node_modules/void-elements/package.json +34 -0
- xinference/web/ui/package-lock.json +69 -3
- xinference/web/ui/package.json +2 -0
- xinference/web/ui/src/locales/en.json +186 -0
- xinference/web/ui/src/locales/zh.json +186 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/METADATA +68 -32
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/RECORD +316 -122
- xinference/thirdparty/cosyvoice/bin/export_trt.py +0 -8
- xinference/thirdparty/fish_speech/tools/api.py +0 -943
- xinference/thirdparty/fish_speech/tools/msgpack_api.py +0 -95
- xinference/thirdparty/fish_speech/tools/webui.py +0 -548
- xinference/web/ui/build/static/css/main.5061c4c3.css +0 -2
- xinference/web/ui/build/static/css/main.5061c4c3.css.map +0 -1
- xinference/web/ui/build/static/js/main.2f269bb3.js +0 -3
- xinference/web/ui/build/static/js/main.2f269bb3.js.map +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/07ce9e632e6aff24d7aa3ad8e48224433bbfeb0d633fca723453f1fcae0c9f1c.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/1130403f9e46f5738a23b45ac59b57de8f360c908c713e2c0670c2cce9bd367a.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/131091b25d26b17cdca187d7542a21475c211138d900cf667682260e76ef9463.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/1f269fb2a368363c1cb2237825f1dba093b6bdd8c44cc05954fd19ec2c1fff03.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/331312668fa8bd3d7401818f4a25fa98135d7f61371cd6bfff78b18cf4fbdd92.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/40f17338fc75ae095de7d2b4d8eae0d5ca0193a7e2bcece4ee745b22a7a2f4b7.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/4de9a6942c5f1749d6cbfdd54279699975f16016b182848bc253886f52ec2ec3.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/822586ed1077201b64b954f12f25e3f9b45678c1acbabe53d8af3ca82ca71f33.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/8d33354bd2100c8602afc3341f131a88cc36aaeecd5a4b365ed038514708e350.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/9375a35b05d56989b2755bf72161fa707c92f28569d33765a75f91a568fda6e9.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/a158a9ffa0c9b169aee53dd4a0c44501a596755b4e4f6ede7746d65a72e2a71f.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/bd6ad8159341315a1764c397621a560809f7eb7219ab5174c801fca7e969d943.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/c7bf40bab396765f67d0fed627ed3665890608b2d0edaa3e8cb7cfc96310db45.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/d6c643278a0b28320e6f33a60f5fb64c053997cbdc39a60e53ccc574688ade9e.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/e42b72d4cc1ea412ebecbb8d040dc6c6bfee462c33903c2f1f3facb602ad742e.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/e64b7e8cedcf43d4c95deba60ec1341855c887705805bb62431693118b870c69.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/f5039ddbeb815c51491a1989532006b96fc3ae49c6c60e3c097f875b4ae915ae.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/f72f011744c4649fabddca6f7a9327861ac0a315a89b1a2e62a39774e7863845.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/feabb04b4aa507102da0a64398a40818e878fd1df9b75dda8461b3e1e7ff3f11.json +0 -1
- /xinference/thirdparty/{cosyvoice/bin → f5_tts}/__init__.py +0 -0
- /xinference/thirdparty/{cosyvoice/flow → melo}/__init__.py +0 -0
- /xinference/thirdparty/{cosyvoice/hifigan → melo/text/english_utils}/__init__.py +0 -0
- /xinference/thirdparty/{cosyvoice/llm → melo/text/es_phonemizer}/__init__.py +0 -0
- /xinference/thirdparty/{fish_speech/tools → melo/text/fr_phonemizer}/__init__.py +0 -0
- /xinference/web/ui/build/static/js/{main.2f269bb3.js.LICENSE.txt → main.b0936c54.js.LICENSE.txt} +0 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/LICENSE +0 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/WHEEL +0 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/entry_points.txt +0 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
hydra:
|
|
2
|
+
run:
|
|
3
|
+
dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
|
4
|
+
|
|
5
|
+
datasets:
|
|
6
|
+
name: Emilia_ZH_EN # dataset name
|
|
7
|
+
batch_size_per_gpu: 38400 # 8 GPUs, 8 * 38400 = 307200
|
|
8
|
+
batch_size_type: frame # "frame" or "sample"
|
|
9
|
+
max_samples: 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models
|
|
10
|
+
num_workers: 16
|
|
11
|
+
|
|
12
|
+
optim:
|
|
13
|
+
epochs: 15
|
|
14
|
+
learning_rate: 7.5e-5
|
|
15
|
+
num_warmup_updates: 20000 # warmup steps
|
|
16
|
+
grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps
|
|
17
|
+
max_grad_norm: 1.0 # gradient clipping
|
|
18
|
+
bnb_optimizer: False # use bnb 8bit AdamW optimizer or not
|
|
19
|
+
|
|
20
|
+
model:
|
|
21
|
+
name: E2TTS_Base
|
|
22
|
+
tokenizer: pinyin
|
|
23
|
+
tokenizer_path: None # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt)
|
|
24
|
+
arch:
|
|
25
|
+
dim: 1024
|
|
26
|
+
depth: 24
|
|
27
|
+
heads: 16
|
|
28
|
+
ff_mult: 4
|
|
29
|
+
mel_spec:
|
|
30
|
+
target_sample_rate: 24000
|
|
31
|
+
n_mel_channels: 100
|
|
32
|
+
hop_length: 256
|
|
33
|
+
win_length: 1024
|
|
34
|
+
n_fft: 1024
|
|
35
|
+
mel_spec_type: vocos # 'vocos' or 'bigvgan'
|
|
36
|
+
vocoder:
|
|
37
|
+
is_local: False # use local offline ckpt or not
|
|
38
|
+
local_path: None # local vocoder path
|
|
39
|
+
|
|
40
|
+
ckpts:
|
|
41
|
+
logger: wandb # wandb | tensorboard | None
|
|
42
|
+
save_per_updates: 50000 # save checkpoint per steps
|
|
43
|
+
last_per_steps: 5000 # save last checkpoint per steps
|
|
44
|
+
save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
hydra:
|
|
2
|
+
run:
|
|
3
|
+
dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
|
4
|
+
|
|
5
|
+
datasets:
|
|
6
|
+
name: Emilia_ZH_EN
|
|
7
|
+
batch_size_per_gpu: 38400 # 8 GPUs, 8 * 38400 = 307200
|
|
8
|
+
batch_size_type: frame # "frame" or "sample"
|
|
9
|
+
max_samples: 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models
|
|
10
|
+
num_workers: 16
|
|
11
|
+
|
|
12
|
+
optim:
|
|
13
|
+
epochs: 15
|
|
14
|
+
learning_rate: 7.5e-5
|
|
15
|
+
num_warmup_updates: 20000 # warmup steps
|
|
16
|
+
grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps
|
|
17
|
+
max_grad_norm: 1.0
|
|
18
|
+
bnb_optimizer: False
|
|
19
|
+
|
|
20
|
+
model:
|
|
21
|
+
name: E2TTS_Small
|
|
22
|
+
tokenizer: pinyin
|
|
23
|
+
tokenizer_path: None # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt)
|
|
24
|
+
arch:
|
|
25
|
+
dim: 768
|
|
26
|
+
depth: 20
|
|
27
|
+
heads: 12
|
|
28
|
+
ff_mult: 4
|
|
29
|
+
mel_spec:
|
|
30
|
+
target_sample_rate: 24000
|
|
31
|
+
n_mel_channels: 100
|
|
32
|
+
hop_length: 256
|
|
33
|
+
win_length: 1024
|
|
34
|
+
n_fft: 1024
|
|
35
|
+
mel_spec_type: vocos # 'vocos' or 'bigvgan'
|
|
36
|
+
vocoder:
|
|
37
|
+
is_local: False # use local offline ckpt or not
|
|
38
|
+
local_path: None # local vocoder path
|
|
39
|
+
|
|
40
|
+
ckpts:
|
|
41
|
+
logger: wandb # wandb | tensorboard | None
|
|
42
|
+
save_per_updates: 50000 # save checkpoint per steps
|
|
43
|
+
last_per_steps: 5000 # save last checkpoint per steps
|
|
44
|
+
save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
hydra:
|
|
2
|
+
run:
|
|
3
|
+
dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
|
4
|
+
|
|
5
|
+
datasets:
|
|
6
|
+
name: Emilia_ZH_EN # dataset name
|
|
7
|
+
batch_size_per_gpu: 38400 # 8 GPUs, 8 * 38400 = 307200
|
|
8
|
+
batch_size_type: frame # "frame" or "sample"
|
|
9
|
+
max_samples: 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models
|
|
10
|
+
num_workers: 16
|
|
11
|
+
|
|
12
|
+
optim:
|
|
13
|
+
epochs: 15
|
|
14
|
+
learning_rate: 7.5e-5
|
|
15
|
+
num_warmup_updates: 20000 # warmup steps
|
|
16
|
+
grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps
|
|
17
|
+
max_grad_norm: 1.0 # gradient clipping
|
|
18
|
+
bnb_optimizer: False # use bnb 8bit AdamW optimizer or not
|
|
19
|
+
|
|
20
|
+
model:
|
|
21
|
+
name: F5TTS_Base # model name
|
|
22
|
+
tokenizer: pinyin # tokenizer type
|
|
23
|
+
tokenizer_path: None # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt)
|
|
24
|
+
arch:
|
|
25
|
+
dim: 1024
|
|
26
|
+
depth: 22
|
|
27
|
+
heads: 16
|
|
28
|
+
ff_mult: 2
|
|
29
|
+
text_dim: 512
|
|
30
|
+
conv_layers: 4
|
|
31
|
+
mel_spec:
|
|
32
|
+
target_sample_rate: 24000
|
|
33
|
+
n_mel_channels: 100
|
|
34
|
+
hop_length: 256
|
|
35
|
+
win_length: 1024
|
|
36
|
+
n_fft: 1024
|
|
37
|
+
mel_spec_type: vocos # 'vocos' or 'bigvgan'
|
|
38
|
+
vocoder:
|
|
39
|
+
is_local: False # use local offline ckpt or not
|
|
40
|
+
local_path: None # local vocoder path
|
|
41
|
+
|
|
42
|
+
ckpts:
|
|
43
|
+
logger: wandb # wandb | tensorboard | None
|
|
44
|
+
save_per_updates: 50000 # save checkpoint per steps
|
|
45
|
+
last_per_steps: 5000 # save last checkpoint per steps
|
|
46
|
+
save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
hydra:
|
|
2
|
+
run:
|
|
3
|
+
dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
|
4
|
+
|
|
5
|
+
datasets:
|
|
6
|
+
name: Emilia_ZH_EN
|
|
7
|
+
batch_size_per_gpu: 38400 # 8 GPUs, 8 * 38400 = 307200
|
|
8
|
+
batch_size_type: frame # "frame" or "sample"
|
|
9
|
+
max_samples: 64 # max sequences per batch if use frame-wise batch_size. we set 32 for small models, 64 for base models
|
|
10
|
+
num_workers: 16
|
|
11
|
+
|
|
12
|
+
optim:
|
|
13
|
+
epochs: 15
|
|
14
|
+
learning_rate: 7.5e-5
|
|
15
|
+
num_warmup_updates: 20000 # warmup steps
|
|
16
|
+
grad_accumulation_steps: 1 # note: updates = steps / grad_accumulation_steps
|
|
17
|
+
max_grad_norm: 1.0 # gradient clipping
|
|
18
|
+
bnb_optimizer: False # use bnb 8bit AdamW optimizer or not
|
|
19
|
+
|
|
20
|
+
model:
|
|
21
|
+
name: F5TTS_Small
|
|
22
|
+
tokenizer: pinyin
|
|
23
|
+
tokenizer_path: None # if tokenizer = 'custom', define the path to the tokenizer you want to use (should be vocab.txt)
|
|
24
|
+
arch:
|
|
25
|
+
dim: 768
|
|
26
|
+
depth: 18
|
|
27
|
+
heads: 12
|
|
28
|
+
ff_mult: 2
|
|
29
|
+
text_dim: 512
|
|
30
|
+
conv_layers: 4
|
|
31
|
+
mel_spec:
|
|
32
|
+
target_sample_rate: 24000
|
|
33
|
+
n_mel_channels: 100
|
|
34
|
+
hop_length: 256
|
|
35
|
+
win_length: 1024
|
|
36
|
+
n_fft: 1024
|
|
37
|
+
mel_spec_type: vocos # 'vocos' or 'bigvgan'
|
|
38
|
+
vocoder:
|
|
39
|
+
is_local: False # use local offline ckpt or not
|
|
40
|
+
local_path: None # local vocoder path
|
|
41
|
+
|
|
42
|
+
ckpts:
|
|
43
|
+
logger: wandb # wandb | tensorboard | None
|
|
44
|
+
save_per_updates: 50000 # save checkpoint per steps
|
|
45
|
+
last_per_steps: 5000 # save last checkpoint per steps
|
|
46
|
+
save_dir: ckpts/${model.name}_${model.mel_spec.mel_spec_type}_${model.tokenizer}_${datasets.name}/${now:%Y-%m-%d}/${now:%H-%M-%S}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
# Evaluation
|
|
3
|
+
|
|
4
|
+
Install packages for evaluation:
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
pip install -e .[eval]
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Generating Samples for Evaluation
|
|
11
|
+
|
|
12
|
+
### Prepare Test Datasets
|
|
13
|
+
|
|
14
|
+
1. *Seed-TTS testset*: Download from [seed-tts-eval](https://github.com/BytedanceSpeech/seed-tts-eval).
|
|
15
|
+
2. *LibriSpeech test-clean*: Download from [OpenSLR](http://www.openslr.org/12/).
|
|
16
|
+
3. Unzip the downloaded datasets and place them in the `data/` directory.
|
|
17
|
+
4. Update the path for *LibriSpeech test-clean* data in `src/f5_tts/eval/eval_infer_batch.py`
|
|
18
|
+
5. Our filtered LibriSpeech-PC 4-10s subset: `data/librispeech_pc_test_clean_cross_sentence.lst`
|
|
19
|
+
|
|
20
|
+
### Batch Inference for Test Set
|
|
21
|
+
|
|
22
|
+
To run batch inference for evaluations, execute the following commands:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# batch inference for evaluations
|
|
26
|
+
accelerate config # if not set before
|
|
27
|
+
bash src/f5_tts/eval/eval_infer_batch.sh
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Objective Evaluation on Generated Results
|
|
31
|
+
|
|
32
|
+
### Download Evaluation Model Checkpoints
|
|
33
|
+
|
|
34
|
+
1. Chinese ASR Model: [Paraformer-zh](https://huggingface.co/funasr/paraformer-zh)
|
|
35
|
+
2. English ASR Model: [Faster-Whisper](https://huggingface.co/Systran/faster-whisper-large-v3)
|
|
36
|
+
3. WavLM Model: Download from [Google Drive](https://drive.google.com/file/d/1-aE1NfzpRCLxA4GUxX9ITI3F9LlbtEGP/view).
|
|
37
|
+
|
|
38
|
+
Then update in the following scripts with the paths you put evaluation model ckpts to.
|
|
39
|
+
|
|
40
|
+
### Objective Evaluation
|
|
41
|
+
|
|
42
|
+
Update the path with your batch-inferenced results, and carry out WER / SIM evaluations:
|
|
43
|
+
```bash
|
|
44
|
+
# Evaluation for Seed-TTS test set
|
|
45
|
+
python src/f5_tts/eval/eval_seedtts_testset.py --gen_wav_dir <GEN_WAVE_DIR>
|
|
46
|
+
|
|
47
|
+
# Evaluation for LibriSpeech-PC test-clean (cross-sentence)
|
|
48
|
+
python src/f5_tts/eval/eval_librispeech_test_clean.py --gen_wav_dir <GEN_WAVE_DIR> --librispeech_test_clean_path <TEST_CLEAN_PATH>
|
|
49
|
+
```
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# just for speaker similarity evaluation, third-party code
|
|
2
|
+
|
|
3
|
+
# From https://github.com/microsoft/UniSpeech/blob/main/downstreams/speaker_verification/models/
|
|
4
|
+
# part of the code is borrowed from https://github.com/lawlict/ECAPA-TDNN
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import torch
|
|
8
|
+
import torch.nn as nn
|
|
9
|
+
import torch.nn.functional as F
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
""" Res2Conv1d + BatchNorm1d + ReLU
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class Res2Conv1dReluBn(nn.Module):
|
|
17
|
+
"""
|
|
18
|
+
in_channels == out_channels == channels
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def __init__(self, channels, kernel_size=1, stride=1, padding=0, dilation=1, bias=True, scale=4):
|
|
22
|
+
super().__init__()
|
|
23
|
+
assert channels % scale == 0, "{} % {} != 0".format(channels, scale)
|
|
24
|
+
self.scale = scale
|
|
25
|
+
self.width = channels // scale
|
|
26
|
+
self.nums = scale if scale == 1 else scale - 1
|
|
27
|
+
|
|
28
|
+
self.convs = []
|
|
29
|
+
self.bns = []
|
|
30
|
+
for i in range(self.nums):
|
|
31
|
+
self.convs.append(nn.Conv1d(self.width, self.width, kernel_size, stride, padding, dilation, bias=bias))
|
|
32
|
+
self.bns.append(nn.BatchNorm1d(self.width))
|
|
33
|
+
self.convs = nn.ModuleList(self.convs)
|
|
34
|
+
self.bns = nn.ModuleList(self.bns)
|
|
35
|
+
|
|
36
|
+
def forward(self, x):
|
|
37
|
+
out = []
|
|
38
|
+
spx = torch.split(x, self.width, 1)
|
|
39
|
+
for i in range(self.nums):
|
|
40
|
+
if i == 0:
|
|
41
|
+
sp = spx[i]
|
|
42
|
+
else:
|
|
43
|
+
sp = sp + spx[i]
|
|
44
|
+
# Order: conv -> relu -> bn
|
|
45
|
+
sp = self.convs[i](sp)
|
|
46
|
+
sp = self.bns[i](F.relu(sp))
|
|
47
|
+
out.append(sp)
|
|
48
|
+
if self.scale != 1:
|
|
49
|
+
out.append(spx[self.nums])
|
|
50
|
+
out = torch.cat(out, dim=1)
|
|
51
|
+
|
|
52
|
+
return out
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
""" Conv1d + BatchNorm1d + ReLU
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class Conv1dReluBn(nn.Module):
|
|
60
|
+
def __init__(self, in_channels, out_channels, kernel_size=1, stride=1, padding=0, dilation=1, bias=True):
|
|
61
|
+
super().__init__()
|
|
62
|
+
self.conv = nn.Conv1d(in_channels, out_channels, kernel_size, stride, padding, dilation, bias=bias)
|
|
63
|
+
self.bn = nn.BatchNorm1d(out_channels)
|
|
64
|
+
|
|
65
|
+
def forward(self, x):
|
|
66
|
+
return self.bn(F.relu(self.conv(x)))
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
""" The SE connection of 1D case.
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class SE_Connect(nn.Module):
|
|
74
|
+
def __init__(self, channels, se_bottleneck_dim=128):
|
|
75
|
+
super().__init__()
|
|
76
|
+
self.linear1 = nn.Linear(channels, se_bottleneck_dim)
|
|
77
|
+
self.linear2 = nn.Linear(se_bottleneck_dim, channels)
|
|
78
|
+
|
|
79
|
+
def forward(self, x):
|
|
80
|
+
out = x.mean(dim=2)
|
|
81
|
+
out = F.relu(self.linear1(out))
|
|
82
|
+
out = torch.sigmoid(self.linear2(out))
|
|
83
|
+
out = x * out.unsqueeze(2)
|
|
84
|
+
|
|
85
|
+
return out
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
""" SE-Res2Block of the ECAPA-TDNN architecture.
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
# def SE_Res2Block(channels, kernel_size, stride, padding, dilation, scale):
|
|
92
|
+
# return nn.Sequential(
|
|
93
|
+
# Conv1dReluBn(channels, 512, kernel_size=1, stride=1, padding=0),
|
|
94
|
+
# Res2Conv1dReluBn(512, kernel_size, stride, padding, dilation, scale=scale),
|
|
95
|
+
# Conv1dReluBn(512, channels, kernel_size=1, stride=1, padding=0),
|
|
96
|
+
# SE_Connect(channels)
|
|
97
|
+
# )
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class SE_Res2Block(nn.Module):
|
|
101
|
+
def __init__(self, in_channels, out_channels, kernel_size, stride, padding, dilation, scale, se_bottleneck_dim):
|
|
102
|
+
super().__init__()
|
|
103
|
+
self.Conv1dReluBn1 = Conv1dReluBn(in_channels, out_channels, kernel_size=1, stride=1, padding=0)
|
|
104
|
+
self.Res2Conv1dReluBn = Res2Conv1dReluBn(out_channels, kernel_size, stride, padding, dilation, scale=scale)
|
|
105
|
+
self.Conv1dReluBn2 = Conv1dReluBn(out_channels, out_channels, kernel_size=1, stride=1, padding=0)
|
|
106
|
+
self.SE_Connect = SE_Connect(out_channels, se_bottleneck_dim)
|
|
107
|
+
|
|
108
|
+
self.shortcut = None
|
|
109
|
+
if in_channels != out_channels:
|
|
110
|
+
self.shortcut = nn.Conv1d(
|
|
111
|
+
in_channels=in_channels,
|
|
112
|
+
out_channels=out_channels,
|
|
113
|
+
kernel_size=1,
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
def forward(self, x):
|
|
117
|
+
residual = x
|
|
118
|
+
if self.shortcut:
|
|
119
|
+
residual = self.shortcut(x)
|
|
120
|
+
|
|
121
|
+
x = self.Conv1dReluBn1(x)
|
|
122
|
+
x = self.Res2Conv1dReluBn(x)
|
|
123
|
+
x = self.Conv1dReluBn2(x)
|
|
124
|
+
x = self.SE_Connect(x)
|
|
125
|
+
|
|
126
|
+
return x + residual
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
""" Attentive weighted mean and standard deviation pooling.
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
class AttentiveStatsPool(nn.Module):
|
|
134
|
+
def __init__(self, in_dim, attention_channels=128, global_context_att=False):
|
|
135
|
+
super().__init__()
|
|
136
|
+
self.global_context_att = global_context_att
|
|
137
|
+
|
|
138
|
+
# Use Conv1d with stride == 1 rather than Linear, then we don't need to transpose inputs.
|
|
139
|
+
if global_context_att:
|
|
140
|
+
self.linear1 = nn.Conv1d(in_dim * 3, attention_channels, kernel_size=1) # equals W and b in the paper
|
|
141
|
+
else:
|
|
142
|
+
self.linear1 = nn.Conv1d(in_dim, attention_channels, kernel_size=1) # equals W and b in the paper
|
|
143
|
+
self.linear2 = nn.Conv1d(attention_channels, in_dim, kernel_size=1) # equals V and k in the paper
|
|
144
|
+
|
|
145
|
+
def forward(self, x):
|
|
146
|
+
if self.global_context_att:
|
|
147
|
+
context_mean = torch.mean(x, dim=-1, keepdim=True).expand_as(x)
|
|
148
|
+
context_std = torch.sqrt(torch.var(x, dim=-1, keepdim=True) + 1e-10).expand_as(x)
|
|
149
|
+
x_in = torch.cat((x, context_mean, context_std), dim=1)
|
|
150
|
+
else:
|
|
151
|
+
x_in = x
|
|
152
|
+
|
|
153
|
+
# DON'T use ReLU here! In experiments, I find ReLU hard to converge.
|
|
154
|
+
alpha = torch.tanh(self.linear1(x_in))
|
|
155
|
+
# alpha = F.relu(self.linear1(x_in))
|
|
156
|
+
alpha = torch.softmax(self.linear2(alpha), dim=2)
|
|
157
|
+
mean = torch.sum(alpha * x, dim=2)
|
|
158
|
+
residuals = torch.sum(alpha * (x**2), dim=2) - mean**2
|
|
159
|
+
std = torch.sqrt(residuals.clamp(min=1e-9))
|
|
160
|
+
return torch.cat([mean, std], dim=1)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
class ECAPA_TDNN(nn.Module):
|
|
164
|
+
def __init__(
|
|
165
|
+
self,
|
|
166
|
+
feat_dim=80,
|
|
167
|
+
channels=512,
|
|
168
|
+
emb_dim=192,
|
|
169
|
+
global_context_att=False,
|
|
170
|
+
feat_type="wavlm_large",
|
|
171
|
+
sr=16000,
|
|
172
|
+
feature_selection="hidden_states",
|
|
173
|
+
update_extract=False,
|
|
174
|
+
config_path=None,
|
|
175
|
+
):
|
|
176
|
+
super().__init__()
|
|
177
|
+
|
|
178
|
+
self.feat_type = feat_type
|
|
179
|
+
self.feature_selection = feature_selection
|
|
180
|
+
self.update_extract = update_extract
|
|
181
|
+
self.sr = sr
|
|
182
|
+
|
|
183
|
+
torch.hub._validate_not_a_forked_repo = lambda a, b, c: True
|
|
184
|
+
try:
|
|
185
|
+
local_s3prl_path = os.path.expanduser("~/.cache/torch/hub/s3prl_s3prl_main")
|
|
186
|
+
self.feature_extract = torch.hub.load(local_s3prl_path, feat_type, source="local", config_path=config_path)
|
|
187
|
+
except: # noqa: E722
|
|
188
|
+
self.feature_extract = torch.hub.load("s3prl/s3prl", feat_type)
|
|
189
|
+
|
|
190
|
+
if len(self.feature_extract.model.encoder.layers) == 24 and hasattr(
|
|
191
|
+
self.feature_extract.model.encoder.layers[23].self_attn, "fp32_attention"
|
|
192
|
+
):
|
|
193
|
+
self.feature_extract.model.encoder.layers[23].self_attn.fp32_attention = False
|
|
194
|
+
if len(self.feature_extract.model.encoder.layers) == 24 and hasattr(
|
|
195
|
+
self.feature_extract.model.encoder.layers[11].self_attn, "fp32_attention"
|
|
196
|
+
):
|
|
197
|
+
self.feature_extract.model.encoder.layers[11].self_attn.fp32_attention = False
|
|
198
|
+
|
|
199
|
+
self.feat_num = self.get_feat_num()
|
|
200
|
+
self.feature_weight = nn.Parameter(torch.zeros(self.feat_num))
|
|
201
|
+
|
|
202
|
+
if feat_type != "fbank" and feat_type != "mfcc":
|
|
203
|
+
freeze_list = ["final_proj", "label_embs_concat", "mask_emb", "project_q", "quantizer"]
|
|
204
|
+
for name, param in self.feature_extract.named_parameters():
|
|
205
|
+
for freeze_val in freeze_list:
|
|
206
|
+
if freeze_val in name:
|
|
207
|
+
param.requires_grad = False
|
|
208
|
+
break
|
|
209
|
+
|
|
210
|
+
if not self.update_extract:
|
|
211
|
+
for param in self.feature_extract.parameters():
|
|
212
|
+
param.requires_grad = False
|
|
213
|
+
|
|
214
|
+
self.instance_norm = nn.InstanceNorm1d(feat_dim)
|
|
215
|
+
# self.channels = [channels] * 4 + [channels * 3]
|
|
216
|
+
self.channels = [channels] * 4 + [1536]
|
|
217
|
+
|
|
218
|
+
self.layer1 = Conv1dReluBn(feat_dim, self.channels[0], kernel_size=5, padding=2)
|
|
219
|
+
self.layer2 = SE_Res2Block(
|
|
220
|
+
self.channels[0],
|
|
221
|
+
self.channels[1],
|
|
222
|
+
kernel_size=3,
|
|
223
|
+
stride=1,
|
|
224
|
+
padding=2,
|
|
225
|
+
dilation=2,
|
|
226
|
+
scale=8,
|
|
227
|
+
se_bottleneck_dim=128,
|
|
228
|
+
)
|
|
229
|
+
self.layer3 = SE_Res2Block(
|
|
230
|
+
self.channels[1],
|
|
231
|
+
self.channels[2],
|
|
232
|
+
kernel_size=3,
|
|
233
|
+
stride=1,
|
|
234
|
+
padding=3,
|
|
235
|
+
dilation=3,
|
|
236
|
+
scale=8,
|
|
237
|
+
se_bottleneck_dim=128,
|
|
238
|
+
)
|
|
239
|
+
self.layer4 = SE_Res2Block(
|
|
240
|
+
self.channels[2],
|
|
241
|
+
self.channels[3],
|
|
242
|
+
kernel_size=3,
|
|
243
|
+
stride=1,
|
|
244
|
+
padding=4,
|
|
245
|
+
dilation=4,
|
|
246
|
+
scale=8,
|
|
247
|
+
se_bottleneck_dim=128,
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# self.conv = nn.Conv1d(self.channels[-1], self.channels[-1], kernel_size=1)
|
|
251
|
+
cat_channels = channels * 3
|
|
252
|
+
self.conv = nn.Conv1d(cat_channels, self.channels[-1], kernel_size=1)
|
|
253
|
+
self.pooling = AttentiveStatsPool(
|
|
254
|
+
self.channels[-1], attention_channels=128, global_context_att=global_context_att
|
|
255
|
+
)
|
|
256
|
+
self.bn = nn.BatchNorm1d(self.channels[-1] * 2)
|
|
257
|
+
self.linear = nn.Linear(self.channels[-1] * 2, emb_dim)
|
|
258
|
+
|
|
259
|
+
def get_feat_num(self):
|
|
260
|
+
self.feature_extract.eval()
|
|
261
|
+
wav = [torch.randn(self.sr).to(next(self.feature_extract.parameters()).device)]
|
|
262
|
+
with torch.no_grad():
|
|
263
|
+
features = self.feature_extract(wav)
|
|
264
|
+
select_feature = features[self.feature_selection]
|
|
265
|
+
if isinstance(select_feature, (list, tuple)):
|
|
266
|
+
return len(select_feature)
|
|
267
|
+
else:
|
|
268
|
+
return 1
|
|
269
|
+
|
|
270
|
+
def get_feat(self, x):
|
|
271
|
+
if self.update_extract:
|
|
272
|
+
x = self.feature_extract([sample for sample in x])
|
|
273
|
+
else:
|
|
274
|
+
with torch.no_grad():
|
|
275
|
+
if self.feat_type == "fbank" or self.feat_type == "mfcc":
|
|
276
|
+
x = self.feature_extract(x) + 1e-6 # B x feat_dim x time_len
|
|
277
|
+
else:
|
|
278
|
+
x = self.feature_extract([sample for sample in x])
|
|
279
|
+
|
|
280
|
+
if self.feat_type == "fbank":
|
|
281
|
+
x = x.log()
|
|
282
|
+
|
|
283
|
+
if self.feat_type != "fbank" and self.feat_type != "mfcc":
|
|
284
|
+
x = x[self.feature_selection]
|
|
285
|
+
if isinstance(x, (list, tuple)):
|
|
286
|
+
x = torch.stack(x, dim=0)
|
|
287
|
+
else:
|
|
288
|
+
x = x.unsqueeze(0)
|
|
289
|
+
norm_weights = F.softmax(self.feature_weight, dim=-1).unsqueeze(-1).unsqueeze(-1).unsqueeze(-1)
|
|
290
|
+
x = (norm_weights * x).sum(dim=0)
|
|
291
|
+
x = torch.transpose(x, 1, 2) + 1e-6
|
|
292
|
+
|
|
293
|
+
x = self.instance_norm(x)
|
|
294
|
+
return x
|
|
295
|
+
|
|
296
|
+
def forward(self, x):
|
|
297
|
+
x = self.get_feat(x)
|
|
298
|
+
|
|
299
|
+
out1 = self.layer1(x)
|
|
300
|
+
out2 = self.layer2(out1)
|
|
301
|
+
out3 = self.layer3(out2)
|
|
302
|
+
out4 = self.layer4(out3)
|
|
303
|
+
|
|
304
|
+
out = torch.cat([out2, out3, out4], dim=1)
|
|
305
|
+
out = F.relu(self.conv(out))
|
|
306
|
+
out = self.bn(self.pooling(out))
|
|
307
|
+
out = self.linear(out)
|
|
308
|
+
|
|
309
|
+
return out
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def ECAPA_TDNN_SMALL(
|
|
313
|
+
feat_dim,
|
|
314
|
+
emb_dim=256,
|
|
315
|
+
feat_type="wavlm_large",
|
|
316
|
+
sr=16000,
|
|
317
|
+
feature_selection="hidden_states",
|
|
318
|
+
update_extract=False,
|
|
319
|
+
config_path=None,
|
|
320
|
+
):
|
|
321
|
+
return ECAPA_TDNN(
|
|
322
|
+
feat_dim=feat_dim,
|
|
323
|
+
channels=512,
|
|
324
|
+
emb_dim=emb_dim,
|
|
325
|
+
feat_type=feat_type,
|
|
326
|
+
sr=sr,
|
|
327
|
+
feature_selection=feature_selection,
|
|
328
|
+
update_extract=update_extract,
|
|
329
|
+
config_path=config_path,
|
|
330
|
+
)
|