xinference 1.1.0__py3-none-any.whl → 1.2.0__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 +72 -66
- xinference/core/model.py +78 -25
- xinference/core/supervisor.py +81 -10
- xinference/core/utils.py +12 -8
- xinference/core/worker.py +32 -0
- xinference/model/audio/core.py +5 -0
- xinference/model/audio/cosyvoice.py +25 -3
- xinference/model/audio/f5tts.py +15 -10
- xinference/model/audio/f5tts_mlx.py +260 -0
- xinference/model/audio/fish_speech.py +35 -111
- xinference/model/audio/model_spec.json +19 -3
- xinference/model/audio/model_spec_modelscope.json +9 -0
- xinference/model/audio/utils.py +32 -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 +2 -0
- xinference/model/llm/llm_family.json +143 -0
- xinference/model/llm/llm_family.py +15 -36
- xinference/model/llm/llm_family_modelscope.json +148 -0
- xinference/model/llm/mlx/core.py +37 -32
- 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/utils.py +28 -3
- xinference/model/llm/vllm/core.py +48 -9
- 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 +112 -0
- xinference/model/llm/vllm/xavier/block_manager.py +71 -0
- xinference/model/llm/vllm/xavier/block_tracker.py +116 -0
- xinference/model/llm/vllm/xavier/engine.py +247 -0
- xinference/model/llm/vllm/xavier/executor.py +132 -0
- xinference/model/llm/vllm/xavier/scheduler.py +422 -0
- xinference/model/llm/vllm/xavier/test/__init__.py +13 -0
- xinference/model/llm/vllm/xavier/test/test_xavier.py +122 -0
- xinference/model/llm/vllm/xavier/transfer.py +298 -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/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/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/types.py +13 -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.1eb206d1.js +3 -0
- xinference/web/ui/build/static/js/main.1eb206d1.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/2213d49de260e1f67c888081b18f120f5225462b829ae57c9e05a05cec83689d.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/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.1.0.dist-info → xinference-1.2.0.dist-info}/METADATA +19 -11
- {xinference-1.1.0.dist-info → xinference-1.2.0.dist-info}/RECORD +178 -111
- xinference/thirdparty/cosyvoice/bin/__init__.py +0 -0
- xinference/thirdparty/cosyvoice/bin/export_trt.py +0 -8
- xinference/thirdparty/cosyvoice/flow/__init__.py +0 -0
- xinference/thirdparty/cosyvoice/hifigan/__init__.py +0 -0
- xinference/thirdparty/cosyvoice/llm/__init__.py +0 -0
- xinference/thirdparty/fish_speech/tools/__init__.py +0 -0
- 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.4eb4ee80.js +0 -3
- xinference/web/ui/build/static/js/main.4eb4ee80.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/8c5eeb02f772d02cbe8b89c05428d0dd41a97866f75f7dc1c2164a67f5a1cf98.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/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/web/ui/build/static/js/{main.4eb4ee80.js.LICENSE.txt → main.1eb206d1.js.LICENSE.txt} +0 -0
- {xinference-1.1.0.dist-info → xinference-1.2.0.dist-info}/LICENSE +0 -0
- {xinference-1.1.0.dist-info → xinference-1.2.0.dist-info}/WHEEL +0 -0
- {xinference-1.1.0.dist-info → xinference-1.2.0.dist-info}/entry_points.txt +0 -0
- {xinference-1.1.0.dist-info → xinference-1.2.0.dist-info}/top_level.txt +0 -0
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
from argparse import ArgumentParser
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
|
|
5
|
-
import httpx
|
|
6
|
-
import ormsgpack
|
|
7
|
-
|
|
8
|
-
from tools.schema import ServeReferenceAudio, ServeTTSRequest
|
|
9
|
-
|
|
10
|
-
api_key = os.environ.get("FISH_API_KEY", "YOUR_API_KEY")
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def audio_request():
|
|
14
|
-
# priority: ref_id > references
|
|
15
|
-
request = ServeTTSRequest(
|
|
16
|
-
text="你说的对, 但是原神是一款由米哈游自主研发的开放世界手游.",
|
|
17
|
-
# reference_id="114514",
|
|
18
|
-
references=[
|
|
19
|
-
ServeReferenceAudio(
|
|
20
|
-
audio=open("lengyue.wav", "rb").read(),
|
|
21
|
-
text=open("lengyue.lab", "r", encoding="utf-8").read(),
|
|
22
|
-
)
|
|
23
|
-
],
|
|
24
|
-
streaming=True,
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
api_key = os.environ.get("FISH_API_KEY", "YOUR_API_KEY")
|
|
28
|
-
|
|
29
|
-
with (
|
|
30
|
-
httpx.Client() as client,
|
|
31
|
-
open("hello.wav", "wb") as f,
|
|
32
|
-
):
|
|
33
|
-
with client.stream(
|
|
34
|
-
"POST",
|
|
35
|
-
"http://127.0.0.1:8080/v1/tts",
|
|
36
|
-
content=ormsgpack.packb(request, option=ormsgpack.OPT_SERIALIZE_PYDANTIC),
|
|
37
|
-
headers={
|
|
38
|
-
"authorization": f"Bearer {api_key}",
|
|
39
|
-
"content-type": "application/msgpack",
|
|
40
|
-
},
|
|
41
|
-
timeout=None,
|
|
42
|
-
) as response:
|
|
43
|
-
for chunk in response.iter_bytes():
|
|
44
|
-
f.write(chunk)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def asr_request(audio_path: Path):
|
|
48
|
-
|
|
49
|
-
# Read the audio file
|
|
50
|
-
with open(
|
|
51
|
-
str(audio_path),
|
|
52
|
-
"rb",
|
|
53
|
-
) as audio_file:
|
|
54
|
-
audio_data = audio_file.read()
|
|
55
|
-
|
|
56
|
-
# Prepare the request data
|
|
57
|
-
request_data = {
|
|
58
|
-
"audio": audio_data,
|
|
59
|
-
"language": "en", # Optional: specify the language
|
|
60
|
-
"ignore_timestamps": False, # Optional: set to True to ignore precise timestamps
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
# Send the request
|
|
64
|
-
with httpx.Client() as client:
|
|
65
|
-
response = client.post(
|
|
66
|
-
"https://api.fish.audio/v1/asr",
|
|
67
|
-
headers={
|
|
68
|
-
"Authorization": f"Bearer {api_key}",
|
|
69
|
-
"Content-Type": "application/msgpack",
|
|
70
|
-
},
|
|
71
|
-
content=ormsgpack.packb(request_data),
|
|
72
|
-
)
|
|
73
|
-
|
|
74
|
-
# Parse the response
|
|
75
|
-
result = response.json()
|
|
76
|
-
|
|
77
|
-
print(f"Transcribed text: {result['text']}")
|
|
78
|
-
print(f"Audio duration: {result['duration']} seconds")
|
|
79
|
-
|
|
80
|
-
for segment in result["segments"]:
|
|
81
|
-
print(f"Segment: {segment['text']}")
|
|
82
|
-
print(f"Start time: {segment['start']}, End time: {segment['end']}")
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
def parse_args():
|
|
86
|
-
parser = ArgumentParser()
|
|
87
|
-
parser.add_argument("--audio_path", type=Path, default="audio/ref/trump.mp3")
|
|
88
|
-
|
|
89
|
-
return parser.parse_args()
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if __name__ == "__main__":
|
|
93
|
-
args = parse_args()
|
|
94
|
-
|
|
95
|
-
asr_request(args.audio_path)
|
|
@@ -1,548 +0,0 @@
|
|
|
1
|
-
import gc
|
|
2
|
-
import html
|
|
3
|
-
import io
|
|
4
|
-
import os
|
|
5
|
-
import queue
|
|
6
|
-
import wave
|
|
7
|
-
from argparse import ArgumentParser
|
|
8
|
-
from functools import partial
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
import gradio as gr
|
|
12
|
-
import librosa
|
|
13
|
-
import numpy as np
|
|
14
|
-
# import pyrootutils
|
|
15
|
-
import torch
|
|
16
|
-
from loguru import logger
|
|
17
|
-
from transformers import AutoTokenizer
|
|
18
|
-
|
|
19
|
-
# pyrootutils.setup_root(__file__, indicator=".project-root", pythonpath=True)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
from fish_speech.i18n import i18n
|
|
23
|
-
from fish_speech.text.chn_text_norm.text import Text as ChnNormedText
|
|
24
|
-
from fish_speech.utils import autocast_exclude_mps, set_seed
|
|
25
|
-
from tools.api import decode_vq_tokens, encode_reference
|
|
26
|
-
from tools.file import AUDIO_EXTENSIONS, list_files
|
|
27
|
-
from tools.llama.generate import (
|
|
28
|
-
GenerateRequest,
|
|
29
|
-
GenerateResponse,
|
|
30
|
-
WrappedGenerateResponse,
|
|
31
|
-
launch_thread_safe_queue,
|
|
32
|
-
)
|
|
33
|
-
from tools.vqgan.inference import load_model as load_decoder_model
|
|
34
|
-
|
|
35
|
-
# Make einx happy
|
|
36
|
-
os.environ["EINX_FILTER_TRACEBACK"] = "false"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
HEADER_MD = f"""# Fish Speech
|
|
40
|
-
|
|
41
|
-
{i18n("A text-to-speech model based on VQ-GAN and Llama developed by [Fish Audio](https://fish.audio).")}
|
|
42
|
-
|
|
43
|
-
{i18n("You can find the source code [here](https://github.com/fishaudio/fish-speech) and models [here](https://huggingface.co/fishaudio/fish-speech-1.4).")}
|
|
44
|
-
|
|
45
|
-
{i18n("Related code and weights are released under CC BY-NC-SA 4.0 License.")}
|
|
46
|
-
|
|
47
|
-
{i18n("We are not responsible for any misuse of the model, please consider your local laws and regulations before using it.")}
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
|
-
TEXTBOX_PLACEHOLDER = i18n("Put your text here.")
|
|
51
|
-
SPACE_IMPORTED = False
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def build_html_error_message(error):
|
|
55
|
-
return f"""
|
|
56
|
-
<div style="color: red;
|
|
57
|
-
font-weight: bold;">
|
|
58
|
-
{html.escape(str(error))}
|
|
59
|
-
</div>
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
@torch.inference_mode()
|
|
64
|
-
def inference(
|
|
65
|
-
text,
|
|
66
|
-
enable_reference_audio,
|
|
67
|
-
reference_audio,
|
|
68
|
-
reference_text,
|
|
69
|
-
max_new_tokens,
|
|
70
|
-
chunk_length,
|
|
71
|
-
top_p,
|
|
72
|
-
repetition_penalty,
|
|
73
|
-
temperature,
|
|
74
|
-
seed="0",
|
|
75
|
-
streaming=False,
|
|
76
|
-
):
|
|
77
|
-
if args.max_gradio_length > 0 and len(text) > args.max_gradio_length:
|
|
78
|
-
return (
|
|
79
|
-
None,
|
|
80
|
-
None,
|
|
81
|
-
i18n("Text is too long, please keep it under {} characters.").format(
|
|
82
|
-
args.max_gradio_length
|
|
83
|
-
),
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
seed = int(seed)
|
|
87
|
-
if seed != 0:
|
|
88
|
-
set_seed(seed)
|
|
89
|
-
logger.warning(f"set seed: {seed}")
|
|
90
|
-
|
|
91
|
-
# Parse reference audio aka prompt
|
|
92
|
-
prompt_tokens = encode_reference(
|
|
93
|
-
decoder_model=decoder_model,
|
|
94
|
-
reference_audio=reference_audio,
|
|
95
|
-
enable_reference_audio=enable_reference_audio,
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
# LLAMA Inference
|
|
99
|
-
request = dict(
|
|
100
|
-
device=decoder_model.device,
|
|
101
|
-
max_new_tokens=max_new_tokens,
|
|
102
|
-
text=text,
|
|
103
|
-
top_p=top_p,
|
|
104
|
-
repetition_penalty=repetition_penalty,
|
|
105
|
-
temperature=temperature,
|
|
106
|
-
compile=args.compile,
|
|
107
|
-
iterative_prompt=chunk_length > 0,
|
|
108
|
-
chunk_length=chunk_length,
|
|
109
|
-
max_length=2048,
|
|
110
|
-
prompt_tokens=prompt_tokens if enable_reference_audio else None,
|
|
111
|
-
prompt_text=reference_text if enable_reference_audio else None,
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
response_queue = queue.Queue()
|
|
115
|
-
llama_queue.put(
|
|
116
|
-
GenerateRequest(
|
|
117
|
-
request=request,
|
|
118
|
-
response_queue=response_queue,
|
|
119
|
-
)
|
|
120
|
-
)
|
|
121
|
-
|
|
122
|
-
if streaming:
|
|
123
|
-
yield wav_chunk_header(), None, None
|
|
124
|
-
|
|
125
|
-
segments = []
|
|
126
|
-
|
|
127
|
-
while True:
|
|
128
|
-
result: WrappedGenerateResponse = response_queue.get()
|
|
129
|
-
if result.status == "error":
|
|
130
|
-
yield None, None, build_html_error_message(result.response)
|
|
131
|
-
break
|
|
132
|
-
|
|
133
|
-
result: GenerateResponse = result.response
|
|
134
|
-
if result.action == "next":
|
|
135
|
-
break
|
|
136
|
-
|
|
137
|
-
with autocast_exclude_mps(
|
|
138
|
-
device_type=decoder_model.device.type, dtype=args.precision
|
|
139
|
-
):
|
|
140
|
-
fake_audios = decode_vq_tokens(
|
|
141
|
-
decoder_model=decoder_model,
|
|
142
|
-
codes=result.codes,
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
fake_audios = fake_audios.float().cpu().numpy()
|
|
146
|
-
segments.append(fake_audios)
|
|
147
|
-
|
|
148
|
-
if streaming:
|
|
149
|
-
wav_header = wav_chunk_header()
|
|
150
|
-
audio_data = (fake_audios * 32768).astype(np.int16).tobytes()
|
|
151
|
-
yield wav_header + audio_data, None, None
|
|
152
|
-
|
|
153
|
-
if len(segments) == 0:
|
|
154
|
-
return (
|
|
155
|
-
None,
|
|
156
|
-
None,
|
|
157
|
-
build_html_error_message(
|
|
158
|
-
i18n("No audio generated, please check the input text.")
|
|
159
|
-
),
|
|
160
|
-
)
|
|
161
|
-
|
|
162
|
-
# No matter streaming or not, we need to return the final audio
|
|
163
|
-
audio = np.concatenate(segments, axis=0)
|
|
164
|
-
yield None, (decoder_model.spec_transform.sample_rate, audio), None
|
|
165
|
-
|
|
166
|
-
if torch.cuda.is_available():
|
|
167
|
-
torch.cuda.empty_cache()
|
|
168
|
-
gc.collect()
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
inference_stream = partial(inference, streaming=True)
|
|
172
|
-
|
|
173
|
-
n_audios = 4
|
|
174
|
-
|
|
175
|
-
global_audio_list = []
|
|
176
|
-
global_error_list = []
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def inference_wrapper(
|
|
180
|
-
text,
|
|
181
|
-
enable_reference_audio,
|
|
182
|
-
reference_audio,
|
|
183
|
-
reference_text,
|
|
184
|
-
max_new_tokens,
|
|
185
|
-
chunk_length,
|
|
186
|
-
top_p,
|
|
187
|
-
repetition_penalty,
|
|
188
|
-
temperature,
|
|
189
|
-
seed,
|
|
190
|
-
batch_infer_num,
|
|
191
|
-
):
|
|
192
|
-
audios = []
|
|
193
|
-
errors = []
|
|
194
|
-
|
|
195
|
-
for _ in range(batch_infer_num):
|
|
196
|
-
result = inference(
|
|
197
|
-
text,
|
|
198
|
-
enable_reference_audio,
|
|
199
|
-
reference_audio,
|
|
200
|
-
reference_text,
|
|
201
|
-
max_new_tokens,
|
|
202
|
-
chunk_length,
|
|
203
|
-
top_p,
|
|
204
|
-
repetition_penalty,
|
|
205
|
-
temperature,
|
|
206
|
-
seed,
|
|
207
|
-
)
|
|
208
|
-
|
|
209
|
-
_, audio_data, error_message = next(result)
|
|
210
|
-
|
|
211
|
-
audios.append(
|
|
212
|
-
gr.Audio(value=audio_data if audio_data else None, visible=True),
|
|
213
|
-
)
|
|
214
|
-
errors.append(
|
|
215
|
-
gr.HTML(value=error_message if error_message else None, visible=True),
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
for _ in range(batch_infer_num, n_audios):
|
|
219
|
-
audios.append(
|
|
220
|
-
gr.Audio(value=None, visible=False),
|
|
221
|
-
)
|
|
222
|
-
errors.append(
|
|
223
|
-
gr.HTML(value=None, visible=False),
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
return None, *audios, *errors
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
def wav_chunk_header(sample_rate=44100, bit_depth=16, channels=1):
|
|
230
|
-
buffer = io.BytesIO()
|
|
231
|
-
|
|
232
|
-
with wave.open(buffer, "wb") as wav_file:
|
|
233
|
-
wav_file.setnchannels(channels)
|
|
234
|
-
wav_file.setsampwidth(bit_depth // 8)
|
|
235
|
-
wav_file.setframerate(sample_rate)
|
|
236
|
-
|
|
237
|
-
wav_header_bytes = buffer.getvalue()
|
|
238
|
-
buffer.close()
|
|
239
|
-
return wav_header_bytes
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
def normalize_text(user_input, use_normalization):
|
|
243
|
-
if use_normalization:
|
|
244
|
-
return ChnNormedText(raw_text=user_input).normalize()
|
|
245
|
-
else:
|
|
246
|
-
return user_input
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
def update_examples():
|
|
250
|
-
examples_dir = Path("references")
|
|
251
|
-
examples_dir.mkdir(parents=True, exist_ok=True)
|
|
252
|
-
example_audios = list_files(examples_dir, AUDIO_EXTENSIONS, recursive=True)
|
|
253
|
-
return gr.Dropdown(choices=example_audios + [""])
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
def build_app():
|
|
257
|
-
with gr.Blocks(theme=gr.themes.Base()) as app:
|
|
258
|
-
gr.Markdown(HEADER_MD)
|
|
259
|
-
|
|
260
|
-
# Use light theme by default
|
|
261
|
-
app.load(
|
|
262
|
-
None,
|
|
263
|
-
None,
|
|
264
|
-
js="() => {const params = new URLSearchParams(window.location.search);if (!params.has('__theme')) {params.set('__theme', '%s');window.location.search = params.toString();}}"
|
|
265
|
-
% args.theme,
|
|
266
|
-
)
|
|
267
|
-
|
|
268
|
-
# Inference
|
|
269
|
-
with gr.Row():
|
|
270
|
-
with gr.Column(scale=3):
|
|
271
|
-
text = gr.Textbox(
|
|
272
|
-
label=i18n("Input Text"), placeholder=TEXTBOX_PLACEHOLDER, lines=10
|
|
273
|
-
)
|
|
274
|
-
refined_text = gr.Textbox(
|
|
275
|
-
label=i18n("Realtime Transform Text"),
|
|
276
|
-
placeholder=i18n(
|
|
277
|
-
"Normalization Result Preview (Currently Only Chinese)"
|
|
278
|
-
),
|
|
279
|
-
lines=5,
|
|
280
|
-
interactive=False,
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
with gr.Row():
|
|
284
|
-
if_refine_text = gr.Checkbox(
|
|
285
|
-
label=i18n("Text Normalization"),
|
|
286
|
-
value=False,
|
|
287
|
-
scale=1,
|
|
288
|
-
)
|
|
289
|
-
|
|
290
|
-
with gr.Row():
|
|
291
|
-
with gr.Column():
|
|
292
|
-
with gr.Tab(label=i18n("Advanced Config")):
|
|
293
|
-
with gr.Row():
|
|
294
|
-
chunk_length = gr.Slider(
|
|
295
|
-
label=i18n("Iterative Prompt Length, 0 means off"),
|
|
296
|
-
minimum=50,
|
|
297
|
-
maximum=300,
|
|
298
|
-
value=200,
|
|
299
|
-
step=8,
|
|
300
|
-
)
|
|
301
|
-
|
|
302
|
-
max_new_tokens = gr.Slider(
|
|
303
|
-
label=i18n(
|
|
304
|
-
"Maximum tokens per batch, 0 means no limit"
|
|
305
|
-
),
|
|
306
|
-
minimum=0,
|
|
307
|
-
maximum=2048,
|
|
308
|
-
value=0, # 0 means no limit
|
|
309
|
-
step=8,
|
|
310
|
-
)
|
|
311
|
-
|
|
312
|
-
with gr.Row():
|
|
313
|
-
top_p = gr.Slider(
|
|
314
|
-
label="Top-P",
|
|
315
|
-
minimum=0.6,
|
|
316
|
-
maximum=0.9,
|
|
317
|
-
value=0.7,
|
|
318
|
-
step=0.01,
|
|
319
|
-
)
|
|
320
|
-
|
|
321
|
-
repetition_penalty = gr.Slider(
|
|
322
|
-
label=i18n("Repetition Penalty"),
|
|
323
|
-
minimum=1,
|
|
324
|
-
maximum=1.5,
|
|
325
|
-
value=1.2,
|
|
326
|
-
step=0.01,
|
|
327
|
-
)
|
|
328
|
-
|
|
329
|
-
with gr.Row():
|
|
330
|
-
temperature = gr.Slider(
|
|
331
|
-
label="Temperature",
|
|
332
|
-
minimum=0.6,
|
|
333
|
-
maximum=0.9,
|
|
334
|
-
value=0.7,
|
|
335
|
-
step=0.01,
|
|
336
|
-
)
|
|
337
|
-
seed = gr.Textbox(
|
|
338
|
-
label="Seed",
|
|
339
|
-
info="0 means randomized inference, otherwise deterministic",
|
|
340
|
-
placeholder="any 32-bit-integer",
|
|
341
|
-
value="0",
|
|
342
|
-
)
|
|
343
|
-
|
|
344
|
-
with gr.Tab(label=i18n("Reference Audio")):
|
|
345
|
-
with gr.Row():
|
|
346
|
-
gr.Markdown(
|
|
347
|
-
i18n(
|
|
348
|
-
"5 to 10 seconds of reference audio, useful for specifying speaker."
|
|
349
|
-
)
|
|
350
|
-
)
|
|
351
|
-
with gr.Row():
|
|
352
|
-
enable_reference_audio = gr.Checkbox(
|
|
353
|
-
label=i18n("Enable Reference Audio"),
|
|
354
|
-
)
|
|
355
|
-
|
|
356
|
-
with gr.Row():
|
|
357
|
-
example_audio_dropdown = gr.Dropdown(
|
|
358
|
-
label=i18n("Select Example Audio"),
|
|
359
|
-
choices=[""],
|
|
360
|
-
value="",
|
|
361
|
-
interactive=True,
|
|
362
|
-
allow_custom_value=True,
|
|
363
|
-
)
|
|
364
|
-
with gr.Row():
|
|
365
|
-
reference_audio = gr.Audio(
|
|
366
|
-
label=i18n("Reference Audio"),
|
|
367
|
-
type="filepath",
|
|
368
|
-
)
|
|
369
|
-
with gr.Row():
|
|
370
|
-
reference_text = gr.Textbox(
|
|
371
|
-
label=i18n("Reference Text"),
|
|
372
|
-
lines=1,
|
|
373
|
-
placeholder="在一无所知中,梦里的一天结束了,一个新的「轮回」便会开始。",
|
|
374
|
-
value="",
|
|
375
|
-
)
|
|
376
|
-
with gr.Tab(label=i18n("Batch Inference")):
|
|
377
|
-
with gr.Row():
|
|
378
|
-
batch_infer_num = gr.Slider(
|
|
379
|
-
label="Batch infer nums",
|
|
380
|
-
minimum=1,
|
|
381
|
-
maximum=n_audios,
|
|
382
|
-
step=1,
|
|
383
|
-
value=1,
|
|
384
|
-
)
|
|
385
|
-
|
|
386
|
-
with gr.Column(scale=3):
|
|
387
|
-
for _ in range(n_audios):
|
|
388
|
-
with gr.Row():
|
|
389
|
-
error = gr.HTML(
|
|
390
|
-
label=i18n("Error Message"),
|
|
391
|
-
visible=True if _ == 0 else False,
|
|
392
|
-
)
|
|
393
|
-
global_error_list.append(error)
|
|
394
|
-
with gr.Row():
|
|
395
|
-
audio = gr.Audio(
|
|
396
|
-
label=i18n("Generated Audio"),
|
|
397
|
-
type="numpy",
|
|
398
|
-
interactive=False,
|
|
399
|
-
visible=True if _ == 0 else False,
|
|
400
|
-
)
|
|
401
|
-
global_audio_list.append(audio)
|
|
402
|
-
|
|
403
|
-
with gr.Row():
|
|
404
|
-
stream_audio = gr.Audio(
|
|
405
|
-
label=i18n("Streaming Audio"),
|
|
406
|
-
streaming=True,
|
|
407
|
-
autoplay=True,
|
|
408
|
-
interactive=False,
|
|
409
|
-
show_download_button=True,
|
|
410
|
-
)
|
|
411
|
-
with gr.Row():
|
|
412
|
-
with gr.Column(scale=3):
|
|
413
|
-
generate = gr.Button(
|
|
414
|
-
value="\U0001F3A7 " + i18n("Generate"), variant="primary"
|
|
415
|
-
)
|
|
416
|
-
generate_stream = gr.Button(
|
|
417
|
-
value="\U0001F3A7 " + i18n("Streaming Generate"),
|
|
418
|
-
variant="primary",
|
|
419
|
-
)
|
|
420
|
-
|
|
421
|
-
text.input(
|
|
422
|
-
fn=normalize_text, inputs=[text, if_refine_text], outputs=[refined_text]
|
|
423
|
-
)
|
|
424
|
-
|
|
425
|
-
def select_example_audio(audio_path):
|
|
426
|
-
audio_path = Path(audio_path)
|
|
427
|
-
if audio_path.is_file():
|
|
428
|
-
lab_file = Path(audio_path.with_suffix(".lab"))
|
|
429
|
-
|
|
430
|
-
if lab_file.exists():
|
|
431
|
-
lab_content = lab_file.read_text(encoding="utf-8").strip()
|
|
432
|
-
else:
|
|
433
|
-
lab_content = ""
|
|
434
|
-
|
|
435
|
-
return str(audio_path), lab_content, True
|
|
436
|
-
return None, "", False
|
|
437
|
-
|
|
438
|
-
# Connect the dropdown to update reference audio and text
|
|
439
|
-
example_audio_dropdown.change(
|
|
440
|
-
fn=update_examples, inputs=[], outputs=[example_audio_dropdown]
|
|
441
|
-
).then(
|
|
442
|
-
fn=select_example_audio,
|
|
443
|
-
inputs=[example_audio_dropdown],
|
|
444
|
-
outputs=[reference_audio, reference_text, enable_reference_audio],
|
|
445
|
-
)
|
|
446
|
-
|
|
447
|
-
# # Submit
|
|
448
|
-
generate.click(
|
|
449
|
-
inference_wrapper,
|
|
450
|
-
[
|
|
451
|
-
refined_text,
|
|
452
|
-
enable_reference_audio,
|
|
453
|
-
reference_audio,
|
|
454
|
-
reference_text,
|
|
455
|
-
max_new_tokens,
|
|
456
|
-
chunk_length,
|
|
457
|
-
top_p,
|
|
458
|
-
repetition_penalty,
|
|
459
|
-
temperature,
|
|
460
|
-
seed,
|
|
461
|
-
batch_infer_num,
|
|
462
|
-
],
|
|
463
|
-
[stream_audio, *global_audio_list, *global_error_list],
|
|
464
|
-
concurrency_limit=1,
|
|
465
|
-
)
|
|
466
|
-
|
|
467
|
-
generate_stream.click(
|
|
468
|
-
inference_stream,
|
|
469
|
-
[
|
|
470
|
-
refined_text,
|
|
471
|
-
enable_reference_audio,
|
|
472
|
-
reference_audio,
|
|
473
|
-
reference_text,
|
|
474
|
-
max_new_tokens,
|
|
475
|
-
chunk_length,
|
|
476
|
-
top_p,
|
|
477
|
-
repetition_penalty,
|
|
478
|
-
temperature,
|
|
479
|
-
seed,
|
|
480
|
-
],
|
|
481
|
-
[stream_audio, global_audio_list[0], global_error_list[0]],
|
|
482
|
-
concurrency_limit=1,
|
|
483
|
-
)
|
|
484
|
-
return app
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
def parse_args():
|
|
488
|
-
parser = ArgumentParser()
|
|
489
|
-
parser.add_argument(
|
|
490
|
-
"--llama-checkpoint-path",
|
|
491
|
-
type=Path,
|
|
492
|
-
default="checkpoints/fish-speech-1.4",
|
|
493
|
-
)
|
|
494
|
-
parser.add_argument(
|
|
495
|
-
"--decoder-checkpoint-path",
|
|
496
|
-
type=Path,
|
|
497
|
-
default="checkpoints/fish-speech-1.4/firefly-gan-vq-fsq-8x1024-21hz-generator.pth",
|
|
498
|
-
)
|
|
499
|
-
parser.add_argument("--decoder-config-name", type=str, default="firefly_gan_vq")
|
|
500
|
-
parser.add_argument("--device", type=str, default="cuda")
|
|
501
|
-
parser.add_argument("--half", action="store_true")
|
|
502
|
-
parser.add_argument("--compile", action="store_true")
|
|
503
|
-
parser.add_argument("--max-gradio-length", type=int, default=0)
|
|
504
|
-
parser.add_argument("--theme", type=str, default="light")
|
|
505
|
-
|
|
506
|
-
return parser.parse_args()
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
if __name__ == "__main__":
|
|
510
|
-
args = parse_args()
|
|
511
|
-
args.precision = torch.half if args.half else torch.bfloat16
|
|
512
|
-
|
|
513
|
-
logger.info("Loading Llama model...")
|
|
514
|
-
llama_queue = launch_thread_safe_queue(
|
|
515
|
-
checkpoint_path=args.llama_checkpoint_path,
|
|
516
|
-
device=args.device,
|
|
517
|
-
precision=args.precision,
|
|
518
|
-
compile=args.compile,
|
|
519
|
-
)
|
|
520
|
-
logger.info("Llama model loaded, loading VQ-GAN model...")
|
|
521
|
-
|
|
522
|
-
decoder_model = load_decoder_model(
|
|
523
|
-
config_name=args.decoder_config_name,
|
|
524
|
-
checkpoint_path=args.decoder_checkpoint_path,
|
|
525
|
-
device=args.device,
|
|
526
|
-
)
|
|
527
|
-
|
|
528
|
-
logger.info("Decoder model loaded, warming up...")
|
|
529
|
-
|
|
530
|
-
# Dry run to check if the model is loaded correctly and avoid the first-time latency
|
|
531
|
-
list(
|
|
532
|
-
inference(
|
|
533
|
-
text="Hello, world!",
|
|
534
|
-
enable_reference_audio=False,
|
|
535
|
-
reference_audio=None,
|
|
536
|
-
reference_text="",
|
|
537
|
-
max_new_tokens=0,
|
|
538
|
-
chunk_length=200,
|
|
539
|
-
top_p=0.7,
|
|
540
|
-
repetition_penalty=1.2,
|
|
541
|
-
temperature=0.7,
|
|
542
|
-
)
|
|
543
|
-
)
|
|
544
|
-
|
|
545
|
-
logger.info("Warming up done, launching the web UI...")
|
|
546
|
-
|
|
547
|
-
app = build_app()
|
|
548
|
-
app.launch(show_api=True)
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
.container{cursor:pointer;display:block}.container,.descriptionCard{border-radius:20px;height:300px;position:relative;width:300px}.descriptionCard{left:-1px;padding:20px;top:-1px}.cardTitle{display:flex;justify-content:space-between}.iconButtonBox{align-items:center;display:flex}.drawerCard{min-height:100%;padding:20px 80px 0;position:relative;width:60vw}.p{-webkit-line-clamp:4;-webkit-box-orient:vertical;display:-webkit-box;font-size:14px;overflow:hidden;padding:0 10px;text-overflow:ellipsis;word-break:break-word}.formContainer{height:80%;overflow:scroll;padding:0 10px}.buttonsContainer{align-items:center;bottom:50px;display:flex;justify-content:space-between;left:100px;position:absolute;right:100px}.buttonContainer{background-color:initial;border-width:0;width:45%}.buttonItem{border:1px solid #e5e7eb;border-radius:4px;padding:5px;width:100%}.instructionText{color:#666;font-size:12px;font-style:italic;margin:30px 0;text-align:center}.iconRow{bottom:20px;justify-content:space-between;left:20px;position:absolute;right:20px}.iconItem,.iconRow{align-items:center;display:flex}.iconItem{flex-direction:column;margin:20px}.boldIconText{font-size:1.2em;font-weight:700}.muiIcon{font-size:1.5em}.smallText{font-size:.8em}.dialogBox{background-color:#fff;height:607px;margin:32px;overflow-x:scroll;width:1241px}.dialogTitle{color:#000;display:flex;justify-content:space-between;padding:20px 20px 7px}.dialogTitle-model_name{font-size:18px;font-weight:700}.pathBox{cursor:pointer;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:160px}.pathBox2{width:300px}.empty{color:#555;font-size:20px;left:50%;position:absolute;top:30%;-webkit-transform:translate(-50%);transform:translate(-50%)}.deleteDialog{align-items:center;display:flex}.warningIcon{color:#ed6c02;margin-right:10px}.jsonDialog{background-color:#fff;border-radius:8px;color:#000;display:flex;flex-direction:column;padding:10px 30px}.jsonDialog-title{align-items:center;display:flex;justify-content:space-between;margin:10px 0 20px}.title-name{font-size:16px;font-weight:700}.main-box{height:500px;width:700px}.textarea-box{border:1px solid #ddd;border-radius:5px;color:#444;height:100%;padding:5px 10px;resize:none;width:100%}.but-box{display:flex;justify-content:end;margin-top:20px}.copyText{color:#666;cursor:pointer;font-size:14px!important}.copyText:hover{color:#1976d2}.formBox{max-height:80vh;max-width:50vw;min-width:50vw;overflow:auto;padding:40px 20px 0 0;position:relative;transition:all .4s ease-in-out}.broaden{max-width:100%;min-width:100%;padding-right:0}.show-json{align-items:center;color:#444;display:flex;position:fixed;right:60px;top:90px}.icon{cursor:pointer;margin-left:20px;position:absolute;right:-40px}.icon:hover{color:#1976d2}.arrow{font-size:24px!important}.jsonBox{min-height:80vh;position:relative;transition:all .4s ease-in-out;width:100%}.hide{overflow:hidden;-webkit-transform:translate(30vw);transform:translate(30vw);width:0}.checkboxWrapper{align-items:center;display:flex;flex-wrap:wrap;width:100%}.jsonBox-header{align-items:center;display:flex;justify-content:space-between}.jsonBox-title{font-weight:700;line-height:40px}.textarea{border:1px solid #ddd;border-radius:5px;color:#444;height:calc(100% - 40px);padding:5px 10px;resize:none;width:100%}.addBtn{margin-left:20px!important}.item{background-color:#eee;border-radius:10px;margin:10px 50px 0;overflow:hidden;padding:20px;position:relative}.item:hover .deleteBtn{-webkit-transform:translateX(-50px);transform:translateX(-50px)}.deleteBtn{background-color:#1976d2;border-radius:25px;height:50px;line-height:70px;position:absolute;right:20px;text-align:center;top:calc(50% - 25px);-webkit-transform:translateX(80px);transform:translateX(80px);transition:all .3s ease-in-out;width:50px}.deleteBtn:hover{box-shadow:0 0 10px #aaa;cursor:pointer}.deleteIcon{color:#fff;font-size:28px!important}.chat_template_box{align-items:start;display:flex;gap:10px}.chat_template_test{width:30%}.chat_template_test_mainBox{border:1px solid #ccc;border-radius:4px;height:137px;overflow:scroll;padding:10px}.chat_template_test_tip{color:rgba(0,0,0,.6);font-size:10px;margin:4px 14px 0}.test_res_box{background-color:#eee;border-radius:4px;margin-top:5px;min-height:55px;padding:10px}.css-19qh8xo-MuiInputBase-input-MuiOutlinedInput-input.Mui-disabled{-webkit-text-fill-color:#000!important}
|
|
2
|
-
/*# sourceMappingURL=main.5061c4c3.css.map*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"static/css/main.5061c4c3.css","mappings":"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","sources":["scenes/launch_model/styles/modelCardStyle.css","components/copyComponent/style.css","scenes/register_model/styles/registerModelStyle.css"],"sourcesContent":[".container {\n display: block;\n position: relative;\n width: 300px;\n height: 300px;\n cursor: pointer;\n border-radius: 20px;\n}\n.descriptionCard {\n position: relative;\n top: -1px;\n left: -1px;\n width: 300px;\n height: 300px;\n padding: 20px;\n border-radius: 20px;\n}\n.cardTitle {\n display: flex;\n justify-content: space-between;\n}\n.iconButtonBox {\n display: flex;\n align-items: center;\n}\n.drawerCard {\n position: relative;\n padding: 20px 80px 0;\n min-height: 100%;\n width: 60vw;\n}\n.p {\n display: -webkit-box;\n -webkit-line-clamp: 4;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n word-break: break-word;\n font-size: 14px;\n padding: 0px 10px;\n}\n.formContainer {\n height: 80%;\n overflow: scroll;\n padding: 0 10px;\n}\n.buttonsContainer {\n position: absolute;\n bottom: 50px;\n left: 100px;\n right: 100px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n.buttonContainer {\n width: 45%;\n border-width: 0px;\n background-color: transparent;\n}\n.buttonItem {\n width: 100%;\n padding: 5px;\n border-radius: 4px;\n border: 1px solid #e5e7eb;\n border-width: 1px;\n border-color: #e5e7eb;\n}\n.instructionText {\n font-size: 12px;\n color: #666666;\n font-style: italic;\n margin: 30px 0;\n text-align: center;\n}\n.iconRow {\n position: absolute;\n bottom: 20px;\n left: 20px;\n right: 20px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n.iconItem {\n display: flex;\n flex-direction: column;\n align-items: center;\n margin: 20px;\n}\n.boldIconText {\n font-weight: bold;\n font-size: 1.2em;\n}\n.muiIcon {\n font-size: 1.5em;\n}\n.smallText {\n font-size: 0.8em;\n}\n.dialogBox {\n width: 1241px;\n height: 607px;\n background-color: #fff;\n margin: 32px;\n overflow-x: scroll;\n}\n.dialogTitle {\n display: flex;\n justify-content: space-between;\n padding: 20px 20px 7px;\n color: #000;\n}\n.dialogTitle-model_name {\n font-size: 18px;\n font-weight: 700;\n}\n.pathBox {\n width: 160px;\n cursor: pointer;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.pathBox2 {\n width: 300px;\n}\n.empty {\n position: absolute;\n left: 50%;\n top: 30%;\n font-size: 20px;\n color: #555;\n transform: translate(-50%, 0);\n}\n.deleteDialog {\n display: flex;\n align-items: center;\n}\n.warningIcon {\n margin-right: 10px;\n color: rgb(237, 108, 2);\n}\n.jsonDialog {\n display: flex;\n flex-direction: column;\n padding: 10px 30px;\n background-color: #fff;\n color: #000;\n border-radius: 8px;\n}\n.jsonDialog-title {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin: 10px 0 20px 0;\n}\n.title-name {\n font-size: 16px;\n font-weight: 700;\n}\n.main-box {\n width: 700px;\n height: 500px;\n}\n.textarea-box {\n width: 100%;\n height: 100%;\n padding: 5px 10px;\n border: 1px solid #ddd;\n border-radius: 5px;\n resize: none;\n color: #444;\n}\n.but-box {\n display: flex;\n justify-content: end;\n margin-top: 20px;\n}\n",".copyText {\n font-size: 14px !important;\n color: #666;\n cursor: pointer;\n}\n\n.copyText:hover {\n color: #1976d2;\n}\n",".formBox {\n position: relative;\n max-width: 50vw;\n min-width: 50vw;\n max-height: 80vh;\n overflow: auto;\n padding: 40px 20px 0 0;\n transition: all 0.4s ease-in-out;\n}\n\n.broaden {\n max-width: 100%;\n min-width: 100%;\n padding-right: 0;\n}\n\n.show-json {\n display: flex;\n align-items: center;\n position: fixed;\n top: 90px;\n right: 60px;\n color: #444;\n}\n\n.icon {\n position: absolute;\n right: -40px;\n cursor: pointer;\n margin-left: 20px;\n}\n\n.icon:hover {\n color: #1976d2;\n}\n\n.arrow {\n font-size: 24px !important;\n}\n\n.jsonBox {\n position: relative;\n min-height: 80vh;\n width: 100%;\n transition: all 0.4s ease-in-out;\n}\n\n.hide {\n width: 0;\n transform: translate(30vw, 0);\n overflow: hidden;\n}\n\n.checkboxWrapper {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n width: 100%;\n}\n\n.jsonBox-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n}\n\n.jsonBox-title {\n line-height: 40px;\n font-weight: 700;\n}\n\n.textarea {\n width: 100%;\n height: calc(100% - 40px);\n padding: 5px 10px;\n border: 1px solid #ddd;\n border-radius: 5px;\n resize: none;\n color: #444;\n}\n\n.addBtn {\n margin-left: 20px !important;\n}\n\n.item {\n position: relative;\n background-color: #eee;\n margin: 10px 50px 0;\n padding: 20px;\n border-radius: 10px;\n overflow: hidden;\n}\n\n.item:hover .deleteBtn {\n transform: translateX(-50px);\n}\n\n.deleteBtn {\n position: absolute;\n right: 20px;\n top: calc(50% - 25px);\n width: 50px;\n height: 50px;\n transform: translateX(80px);\n text-align: center;\n line-height: 70px;\n border-radius: 25px;\n background-color: #1976d2;\n transition: all 0.3s ease-in-out;\n}\n\n.deleteBtn:hover {\n cursor: pointer;\n box-shadow: 0 0 10px #aaa;\n}\n\n.deleteIcon {\n font-size: 28px !important;\n color: #fff;\n}\n\n.chat_template_box {\n display: flex;\n align-items: start;\n gap: 10px;\n}\n\n.chat_template_test {\n width: 30%;\n}\n\n.chat_template_test_mainBox {\n height: 137px;\n padding: 10px;\n border: 1px solid #ccc;\n border-radius: 4px;\n overflow: scroll;\n}\n\n.chat_template_test_tip {\n font-size: 10px;\n margin: 4px 14px 0;\n color: rgba(0, 0, 0, 0.6);\n}\n\n.test_res_box {\n background-color: #eee;\n min-height: 55px;\n padding: 10px;\n margin-top: 5px;\n border-radius: 4px;\n}\n\n.css-19qh8xo-MuiInputBase-input-MuiOutlinedInput-input.Mui-disabled {\n -webkit-text-fill-color: #000 !important;\n}\n"],"names":[],"sourceRoot":""}
|