SOTA Open Source TTS
Add rust data server
Lengyue57755e1e747f
diff --git a/.dockerignore b/.dockerignoreindex 580c0bc..78eb259 100644--- a/.dockerignore+++ b/.dockerignore@@ -1,3 +1,4 @@resultsdata*.filelist+/data_server/targetdiff --git a/.gitignore b/.gitignoreindex 3309046..7ccb911 100644--- a/.gitignore+++ b/.gitignore@@ -10,3 +10,4 @@ filelists/fish_speech/text/cmudict_cache.pickle/checkpoints/.vscode+/data_server/targetdiff --git a/README.md b/README.mdindex e866162..d12bc7a 100644--- a/README.md+++ b/README.md@@ -16,6 +16,14 @@ pip3 install ninja && MAX_JOBS=4 pip3 install flash-attn --no-build-isolationpip3 install -e .```+## Rust Data Server+Since loading and shuffle the dataset is very slow and memory consuming, we use a rust server to load and shuffle the dataset. The server is based on GRPC and can be installed by++```bash+cd data_server+cargo build --release+```+## Credits- [VITS2 (daniilrobnikov)](https://github.com/daniilrobnikov/vits2)- [Bert-VITS2](https://github.com/fishaudio/Bert-VITS2)diff --git a/data_server/Cargo.lock b/data_server/Cargo.locknew file mode 100644index 0000000..9b37bf1--- /dev/null+++ b/data_server/Cargo.lock@@ -0,0 +1,1403 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 3++[[package]]+name = "addr2line"+version = "0.21.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb"+dependencies = [+ "gimli",+]++[[package]]+name = "adler"+version = "1.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"++[[package]]+name = "aho-corasick"+version = "1.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0"+dependencies = [+ "memchr",+]++[[package]]+name = "anstream"+version = "0.6.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44"+dependencies = [+ "anstyle",+ "anstyle-parse",+ "anstyle-query",+ "anstyle-wincon",+ "colorchoice",+ "utf8parse",+]++[[package]]+name = "anstyle"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"++[[package]]+name = "anstyle-parse"+version = "0.2.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c"+dependencies = [+ "utf8parse",+]++[[package]]+name = "anstyle-query"+version = "1.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a3a318f1f38d2418400f8209655bfd825785afd25aa30bb7ba6cc792e4596748"+dependencies = [+ "windows-sys 0.52.0",+]++[[package]]+name = "anstyle-wincon"+version = "3.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7"+dependencies = [+ "anstyle",+ "windows-sys 0.52.0",+]++[[package]]+name = "anyhow"+version = "1.0.75"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"++[[package]]+name = "async-stream"+version = "0.3.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51"+dependencies = [+ "async-stream-impl",+ "futures-core",+ "pin-project-lite",+]++[[package]]+name = "async-stream-impl"+version = "0.3.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "async-trait"+version = "0.1.74"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "autocfg"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"++[[package]]+name = "axum"+version = "0.6.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf"+dependencies = [+ "async-trait",+ "axum-core",+ "bitflags 1.3.2",+ "bytes",+ "futures-util",+ "http",+ "http-body",+ "hyper",+ "itoa",+ "matchit",+ "memchr",+ "mime",+ "percent-encoding",+ "pin-project-lite",+ "rustversion",+ "serde",+ "sync_wrapper",+ "tower",+ "tower-layer",+ "tower-service",+]++[[package]]+name = "axum-core"+version = "0.3.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c"+dependencies = [+ "async-trait",+ "bytes",+ "futures-util",+ "http",+ "http-body",+ "mime",+ "rustversion",+ "tower-layer",+ "tower-service",+]++[[package]]+name = "backtrace"+version = "0.3.69"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"+dependencies = [+ "addr2line",+ "cc",+ "cfg-if",+ "libc",+ "miniz_oxide",+ "object",+ "rustc-demangle",+]++[[package]]+name = "base64"+version = "0.21.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"++[[package]]+name = "bitflags"+version = "1.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"++[[package]]+name = "bitflags"+version = "2.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"++[[package]]+name = "bytes"+version = "1.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"++[[package]]+name = "cc"+version = "1.0.83"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"+dependencies = [+ "libc",+]++[[package]]+name = "cfg-if"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"++[[package]]+name = "clap"+version = "4.4.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2"+dependencies = [+ "clap_builder",+ "clap_derive",+]++[[package]]+name = "clap_builder"+version = "4.4.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb"+dependencies = [+ "anstream",+ "anstyle",+ "clap_lex",+ "strsim",+]++[[package]]+name = "clap_derive"+version = "4.4.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"+dependencies = [+ "heck",+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "clap_lex"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"++[[package]]+name = "colorchoice"+version = "1.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7"++[[package]]+name = "data_server"+version = "0.1.0"+dependencies = [+ "bytes",+ "clap",+ "env_logger",+ "log",+ "prost",+ "rand",+ "tokio",+ "tonic",+ "tonic-build",+]++[[package]]+name = "either"+version = "1.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"++[[package]]+name = "env_logger"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "95b3f3e67048839cb0d0781f445682a35113da7121f7c949db0e2be96a4fbece"+dependencies = [+ "humantime",+ "is-terminal",+ "log",+ "regex",+ "termcolor",+]++[[package]]+name = "equivalent"+version = "1.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"++[[package]]+name = "errno"+version = "0.3.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245"+dependencies = [+ "libc",+ "windows-sys 0.52.0",+]++[[package]]+name = "fastrand"+version = "2.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5"++[[package]]+name = "fixedbitset"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"++[[package]]+name = "fnv"+version = "1.0.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"++[[package]]+name = "futures-channel"+version = "0.3.29"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb"+dependencies = [+ "futures-core",+]++[[package]]+name = "futures-core"+version = "0.3.29"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c"++[[package]]+name = "futures-sink"+version = "0.3.29"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e36d3378ee38c2a36ad710c5d30c2911d752cb941c00c72dbabfb786a7970817"++[[package]]+name = "futures-task"+version = "0.3.29"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2"++[[package]]+name = "futures-util"+version = "0.3.29"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104"+dependencies = [+ "futures-core",+ "futures-task",+ "pin-project-lite",+ "pin-utils",+]++[[package]]+name = "getrandom"+version = "0.2.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"+dependencies = [+ "cfg-if",+ "libc",+ "wasi",+]++[[package]]+name = "gimli"+version = "0.28.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"++[[package]]+name = "h2"+version = "0.3.22"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178"+dependencies = [+ "bytes",+ "fnv",+ "futures-core",+ "futures-sink",+ "futures-util",+ "http",+ "indexmap 2.1.0",+ "slab",+ "tokio",+ "tokio-util",+ "tracing",+]++[[package]]+name = "hashbrown"+version = "0.12.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"++[[package]]+name = "hashbrown"+version = "0.14.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"++[[package]]+name = "heck"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"++[[package]]+name = "hermit-abi"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"++[[package]]+name = "home"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5444c27eef6923071f7ebcc33e3444508466a76f7a2b93da00ed6e19f30c1ddb"+dependencies = [+ "windows-sys 0.48.0",+]++[[package]]+name = "http"+version = "0.2.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb"+dependencies = [+ "bytes",+ "fnv",+ "itoa",+]++[[package]]+name = "http-body"+version = "0.4.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1"+dependencies = [+ "bytes",+ "http",+ "pin-project-lite",+]++[[package]]+name = "httparse"+version = "1.8.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"++[[package]]+name = "httpdate"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"++[[package]]+name = "humantime"+version = "2.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"++[[package]]+name = "hyper"+version = "0.14.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ffb1cfd654a8219eaef89881fdb3bb3b1cdc5fa75ded05d6933b2b382e395468"+dependencies = [+ "bytes",+ "futures-channel",+ "futures-core",+ "futures-util",+ "h2",+ "http",+ "http-body",+ "httparse",+ "httpdate",+ "itoa",+ "pin-project-lite",+ "socket2 0.4.10",+ "tokio",+ "tower-service",+ "tracing",+ "want",+]++[[package]]+name = "hyper-timeout"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1"+dependencies = [+ "hyper",+ "pin-project-lite",+ "tokio",+ "tokio-io-timeout",+]++[[package]]+name = "indexmap"+version = "1.9.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"+dependencies = [+ "autocfg",+ "hashbrown 0.12.3",+]++[[package]]+name = "indexmap"+version = "2.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"+dependencies = [+ "equivalent",+ "hashbrown 0.14.3",+]++[[package]]+name = "is-terminal"+version = "0.4.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"+dependencies = [+ "hermit-abi",+ "rustix",+ "windows-sys 0.48.0",+]++[[package]]+name = "itertools"+version = "0.11.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57"+dependencies = [+ "either",+]++[[package]]+name = "itoa"+version = "1.0.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"++[[package]]+name = "libc"+version = "0.2.150"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"++[[package]]+name = "linux-raw-sys"+version = "0.4.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"++[[package]]+name = "lock_api"+version = "0.4.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"+dependencies = [+ "autocfg",+ "scopeguard",+]++[[package]]+name = "log"+version = "0.4.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"++[[package]]+name = "matchit"+version = "0.7.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"++[[package]]+name = "memchr"+version = "2.6.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"++[[package]]+name = "mime"+version = "0.3.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"++[[package]]+name = "miniz_oxide"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"+dependencies = [+ "adler",+]++[[package]]+name = "mio"+version = "0.8.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09"+dependencies = [+ "libc",+ "wasi",+ "windows-sys 0.48.0",+]++[[package]]+name = "multimap"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a"++[[package]]+name = "num_cpus"+version = "1.16.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"+dependencies = [+ "hermit-abi",+ "libc",+]++[[package]]+name = "object"+version = "0.32.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"+dependencies = [+ "memchr",+]++[[package]]+name = "once_cell"+version = "1.19.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"++[[package]]+name = "parking_lot"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"+dependencies = [+ "lock_api",+ "parking_lot_core",+]++[[package]]+name = "parking_lot_core"+version = "0.9.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"+dependencies = [+ "cfg-if",+ "libc",+ "redox_syscall",+ "smallvec",+ "windows-targets 0.48.5",+]++[[package]]+name = "percent-encoding"+version = "2.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"++[[package]]+name = "petgraph"+version = "0.6.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9"+dependencies = [+ "fixedbitset",+ "indexmap 2.1.0",+]++[[package]]+name = "pin-project"+version = "1.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fda4ed1c6c173e3fc7a83629421152e01d7b1f9b7f65fb301e490e8cfc656422"+dependencies = [+ "pin-project-internal",+]++[[package]]+name = "pin-project-internal"+version = "1.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4359fd9c9171ec6e8c62926d6faaf553a8dc3f64e1507e76da7911b4f6a04405"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "pin-project-lite"+version = "0.2.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"++[[package]]+name = "pin-utils"+version = "0.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"++[[package]]+name = "ppv-lite86"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"++[[package]]+name = "prettyplease"+version = "0.2.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d"+dependencies = [+ "proc-macro2",+ "syn",+]++[[package]]+name = "proc-macro2"+version = "1.0.70"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "prost"+version = "0.12.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a"+dependencies = [+ "bytes",+ "prost-derive",+]++[[package]]+name = "prost-build"+version = "0.12.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2"+dependencies = [+ "bytes",+ "heck",+ "itertools",+ "log",+ "multimap",+ "once_cell",+ "petgraph",+ "prettyplease",+ "prost",+ "prost-types",+ "regex",+ "syn",+ "tempfile",+ "which",+]++[[package]]+name = "prost-derive"+version = "0.12.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e"+dependencies = [+ "anyhow",+ "itertools",+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "prost-types"+version = "0.12.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e"+dependencies = [+ "prost",+]++[[package]]+name = "quote"+version = "1.0.33"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"+dependencies = [+ "proc-macro2",+]++[[package]]+name = "rand"+version = "0.8.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"+dependencies = [+ "libc",+ "rand_chacha",+ "rand_core",+]++[[package]]+name = "rand_chacha"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"+dependencies = [+ "ppv-lite86",+ "rand_core",+]++[[package]]+name = "rand_core"+version = "0.6.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"+dependencies = [+ "getrandom",+]++[[package]]+name = "redox_syscall"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"+dependencies = [+ "bitflags 1.3.2",+]++[[package]]+name = "regex"+version = "1.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"+dependencies = [+ "aho-corasick",+ "memchr",+ "regex-automata",+ "regex-syntax",+]++[[package]]+name = "regex-automata"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"+dependencies = [+ "aho-corasick",+ "memchr",+ "regex-syntax",+]++[[package]]+name = "regex-syntax"+version = "0.8.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"++[[package]]+name = "rustc-demangle"+version = "0.1.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"++[[package]]+name = "rustix"+version = "0.38.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bfeae074e687625746172d639330f1de242a178bf3189b51e35a7a21573513ac"+dependencies = [+ "bitflags 2.4.1",+ "errno",+ "libc",+ "linux-raw-sys",+ "windows-sys 0.52.0",+]++[[package]]+name = "rustversion"+version = "1.0.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4"++[[package]]+name = "scopeguard"+version = "1.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"++[[package]]+name = "serde"+version = "1.0.193"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"+dependencies = [+ "serde_derive",+]++[[package]]+name = "serde_derive"+version = "1.0.193"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "signal-hook-registry"+version = "1.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1"+dependencies = [+ "libc",+]++[[package]]+name = "slab"+version = "0.4.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"+dependencies = [+ "autocfg",+]++[[package]]+name = "smallvec"+version = "1.11.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"++[[package]]+name = "socket2"+version = "0.4.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d"+dependencies = [+ "libc",+ "winapi",+]++[[package]]+name = "socket2"+version = "0.5.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"+dependencies = [+ "libc",+ "windows-sys 0.48.0",+]++[[package]]+name = "strsim"+version = "0.10.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"++[[package]]+name = "syn"+version = "2.0.39"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]++[[package]]+name = "sync_wrapper"+version = "0.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"++[[package]]+name = "tempfile"+version = "3.8.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5"+dependencies = [+ "cfg-if",+ "fastrand",+ "redox_syscall",+ "rustix",+ "windows-sys 0.48.0",+]++[[package]]+name = "termcolor"+version = "1.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff1bc3d3f05aff0403e8ac0d92ced918ec05b666a43f83297ccef5bea8a3d449"+dependencies = [+ "winapi-util",+]++[[package]]+name = "tokio"+version = "1.34.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9"+dependencies = [+ "backtrace",+ "bytes",+ "libc",+ "mio",+ "num_cpus",+ "parking_lot",+ "pin-project-lite",+ "signal-hook-registry",+ "socket2 0.5.5",+ "tokio-macros",+ "windows-sys 0.48.0",+]++[[package]]+name = "tokio-io-timeout"+version = "1.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf"+dependencies = [+ "pin-project-lite",+ "tokio",+]++[[package]]+name = "tokio-macros"+version = "2.2.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "tokio-stream"+version = "0.1.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "397c988d37662c7dda6d2208364a706264bf3d6138b11d436cbac0ad38832842"+dependencies = [+ "futures-core",+ "pin-project-lite",+ "tokio",+]++[[package]]+name = "tokio-util"+version = "0.7.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5419f34732d9eb6ee4c3578b7989078579b7f039cbbb9ca2c4da015749371e15"+dependencies = [+ "bytes",+ "futures-core",+ "futures-sink",+ "pin-project-lite",+ "tokio",+ "tracing",+]++[[package]]+name = "tonic"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e"+dependencies = [+ "async-stream",+ "async-trait",+ "axum",+ "base64",+ "bytes",+ "h2",+ "http",+ "http-body",+ "hyper",+ "hyper-timeout",+ "percent-encoding",+ "pin-project",+ "prost",+ "tokio",+ "tokio-stream",+ "tower",+ "tower-layer",+ "tower-service",+ "tracing",+]++[[package]]+name = "tonic-build"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889"+dependencies = [+ "prettyplease",+ "proc-macro2",+ "prost-build",+ "quote",+ "syn",+]++[[package]]+name = "tower"+version = "0.4.13"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"+dependencies = [+ "futures-core",+ "futures-util",+ "indexmap 1.9.3",+ "pin-project",+ "pin-project-lite",+ "rand",+ "slab",+ "tokio",+ "tokio-util",+ "tower-layer",+ "tower-service",+ "tracing",+]++[[package]]+name = "tower-layer"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"++[[package]]+name = "tower-service"+version = "0.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52"++[[package]]+name = "tracing"+version = "0.1.40"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef"+dependencies = [+ "pin-project-lite",+ "tracing-attributes",+ "tracing-core",+]++[[package]]+name = "tracing-attributes"+version = "0.1.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "tracing-core"+version = "0.1.32"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54"+dependencies = [+ "once_cell",+]++[[package]]+name = "try-lock"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"++[[package]]+name = "unicode-ident"+version = "1.0.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"++[[package]]+name = "utf8parse"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"++[[package]]+name = "want"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"+dependencies = [+ "try-lock",+]++[[package]]+name = "wasi"+version = "0.11.0+wasi-snapshot-preview1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"++[[package]]+name = "which"+version = "4.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"+dependencies = [+ "either",+ "home",+ "once_cell",+ "rustix",+]++[[package]]+name = "winapi"+version = "0.3.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"+dependencies = [+ "winapi-i686-pc-windows-gnu",+ "winapi-x86_64-pc-windows-gnu",+]++[[package]]+name = "winapi-i686-pc-windows-gnu"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"++[[package]]+name = "winapi-util"+version = "0.1.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"+dependencies = [+ "winapi",+]++[[package]]+name = "winapi-x86_64-pc-windows-gnu"+version = "0.4.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"++[[package]]+name = "windows-sys"+version = "0.48.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"+dependencies = [+ "windows-targets 0.48.5",+]++[[package]]+name = "windows-sys"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"+dependencies = [+ "windows-targets 0.52.0",+]++[[package]]+name = "windows-targets"+version = "0.48.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"+dependencies = [+ "windows_aarch64_gnullvm 0.48.5",+ "windows_aarch64_msvc 0.48.5",+ "windows_i686_gnu 0.48.5",+ "windows_i686_msvc 0.48.5",+ "windows_x86_64_gnu 0.48.5",+ "windows_x86_64_gnullvm 0.48.5",+ "windows_x86_64_msvc 0.48.5",+]++[[package]]+name = "windows-targets"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"+dependencies = [+ "windows_aarch64_gnullvm 0.52.0",+ "windows_aarch64_msvc 0.52.0",+ "windows_i686_gnu 0.52.0",+ "windows_i686_msvc 0.52.0",+ "windows_x86_64_gnu 0.52.0",+ "windows_x86_64_gnullvm 0.52.0",+ "windows_x86_64_msvc 0.52.0",+]++[[package]]+name = "windows_aarch64_gnullvm"+version = "0.48.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"++[[package]]+name = "windows_aarch64_gnullvm"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"++[[package]]+name = "windows_aarch64_msvc"+version = "0.48.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"++[[package]]+name = "windows_aarch64_msvc"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"++[[package]]+name = "windows_i686_gnu"+version = "0.48.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"++[[package]]+name = "windows_i686_gnu"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"++[[package]]+name = "windows_i686_msvc"+version = "0.48.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"++[[package]]+name = "windows_i686_msvc"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"++[[package]]+name = "windows_x86_64_gnu"+version = "0.48.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"++[[package]]+name = "windows_x86_64_gnu"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"++[[package]]+name = "windows_x86_64_gnullvm"+version = "0.48.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"++[[package]]+name = "windows_x86_64_gnullvm"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"++[[package]]+name = "windows_x86_64_msvc"+version = "0.48.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"++[[package]]+name = "windows_x86_64_msvc"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"diff --git a/data_server/Cargo.toml b/data_server/Cargo.tomlnew file mode 100644index 0000000..94f2f95--- /dev/null+++ b/data_server/Cargo.toml@@ -0,0 +1,19 @@+[package]+name = "data_server"+version = "0.1.0"+edition = "2021"++# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html++[dependencies]+bytes = "1.5.0"+clap = { version = "4.4.11", features = ["derive"] }+env_logger = "0.10.1"+log = "0.4.20"+prost = "0.12.3"+rand = "0.8.5"+tokio = { version = "1.34.0", features = ["full"] }+tonic = "0.10.2"++[build-dependencies]+tonic-build = "0.10.2"diff --git a/data_server/build.rs b/data_server/build.rsnew file mode 100644index 0000000..c094d10--- /dev/null+++ b/data_server/build.rs@@ -0,0 +1,4 @@+fn main() -> Result<(), Box<dyn std::error::Error>> {+ tonic_build::compile_protos("../fish_speech/datasets/protos/text-data.proto")?;+ Ok(())+}diff --git a/data_server/src/main.rs b/data_server/src/main.rsnew file mode 100644index 0000000..60d8261--- /dev/null+++ b/data_server/src/main.rs@@ -0,0 +1,143 @@+use clap::Parser;+use log::info;+use prost::Message;+use rand::prelude::IteratorRandom;+use rand::seq::SliceRandom;+use rand::thread_rng;+use std::fs::File;+use std::io::{self, BufReader, Read, Result as IoResult};+use std::vec;+use tonic::{transport::Server, Request, Response, Status};++pub mod text_data {+ tonic::include_proto!("text_data");+}++use text_data::{+ data_service_server::{DataService, DataServiceServer},+ SampleDataRequest, SampledData, Sentence, TextData,+};++#[derive(Default)]+pub struct MyDataService {+ groups: Vec<TextData>,+ weights: Vec<f32>,+}++fn read_pb_stream<R: Read>(mut reader: BufReader<R>) -> io::Result<Vec<TextData>> {+ let mut text_data_list = Vec::new();+ let mut index = 0;++ loop {+ let mut size_buf = [0u8; 4];+ match reader.read_exact(&mut size_buf) {+ Ok(()) => (),+ Err(ref e) if e.kind() == io::ErrorKind::UnexpectedEof => break, // End of file+ Err(e) => return Err(e),+ }++ let size = u32::from_le_bytes(size_buf) as usize;++ let mut message_buf = vec![0u8; size];+ reader.read_exact(&mut message_buf)?;++ let text_data = TextData::decode(&message_buf[..])+ .map_err(|e| io::Error::new(io::ErrorKind::InvalidData, e))?;+ text_data_list.push(text_data);++ index += 1;++ if index % 10000 == 0 {+ info!("Loaded {} groups", index);+ }+ }++ Ok(text_data_list)+}++impl MyDataService {+ pub fn new(files: Vec<String>) -> IoResult<Self> {+ let mut groups = Vec::new();+ let mut weights = Vec::new();++ for filename in files.iter() {+ let file = File::open(filename)?;+ let reader = BufReader::new(file);++ // Assuming read_pb_stream is implemented and it returns an iterator over TextData+ for text_data in read_pb_stream(reader)? {+ groups.push(text_data.clone());+ weights.push(text_data.sentences.len() as f32); // Assuming sentences is a repeated field in TextData+ }+ }++ info!("Loaded {} groups", groups.len());++ Ok(MyDataService { groups, weights })+ }+}++#[tonic::async_trait]+impl DataService for MyDataService {+ async fn sample_data(+ &self,+ request: Request<SampleDataRequest>,+ ) -> Result<Response<SampledData>, Status> {+ let mut num_samples = request.into_inner().num_samples as usize;+ let mut rng = thread_rng();++ let group = self+ .groups+ .choose_weighted(&mut rng, |item| item.sentences.len() as f32);++ if group.is_ok() {+ let group = group.unwrap();+ if num_samples > group.sentences.len() {+ num_samples = group.sentences.len();+ }++ let sentences_ref = group+ .sentences+ .iter()+ .choose_multiple(&mut rng, num_samples);++ let sentences: Vec<Sentence> = sentences_ref+ .into_iter()+ .cloned() // Clone each &Sentence to get Sentence+ .collect();++ Ok(Response::new(SampledData { samples: sentences }))+ } else {+ Err(Status::internal("Failed to select a group"))+ }+ }+}++/// My Data Service Application+#[derive(Parser, Debug)]+#[clap(author, version, about, long_about = None)]+struct Args {+ /// Files to process+ #[clap(short, long, value_name = "FILE", required = true)]+ files: Vec<String>,+}++#[tokio::main]+async fn main() -> Result<(), Box<dyn std::error::Error>> {+ env_logger::init();++ // Parse command-line arguments+ let args = Args::parse();++ let addr = "[::1]:50051".parse()?;+ let data_service = MyDataService::new(args.files)?;++ info!("Starting server at {}", addr);++ Server::builder()+ .add_service(DataServiceServer::new(data_service))+ .serve(addr)+ .await?;++ Ok(())+}diff --git a/fish_speech/datasets/data_server.py b/fish_speech/datasets/data_server.pynew file mode 100644index 0000000..7afc1eb--- /dev/null+++ b/fish_speech/datasets/data_server.py@@ -0,0 +1,83 @@+import asyncio+import random++import grpc+from loguru import logger++from fish_speech.datasets.protos.text_data_pb2 import SampleDataRequest, SampledData+from fish_speech.datasets.protos.text_data_pb2_grpc import (+ DataServiceServicer,+ DataServiceStub,+ add_DataServiceServicer_to_server,+)+from fish_speech.datasets.protos.text_data_stream import read_pb_stream+++class DataService(DataServiceServicer):+ def __init__(+ self,+ files: list[str],+ ):+ super().__init__()++ self.files = files++ # Read all lines, and group by speaker+ self.groups = []+ self.weights = []++ count = 0+ for filename in self.files:+ with open(filename, "rb") as f:+ for text_data in read_pb_stream(f):+ self.groups.append(text_data)+ self.weights.append(len(text_data.sentences))+ count += 1++ if count % 10000 == 0:+ logger.info(f"Read {count} groups of text data")+ break++ def SampleData(self, request: SampleDataRequest, context):+ group = random.choices(self.groups, weights=self.weights, k=1)[0]+ k = min(request.num_samples, len(group.sentences))+ samples = random.choices(group.sentences, k=k)++ return SampledData(+ samples=samples,+ )+++async def run():+ async with grpc.aio.insecure_channel("localhost:50051") as channel:+ stub = DataServiceStub(channel)+ import time++ from tqdm import tqdm++ start = time.time()+ for _ in tqdm(range(10000)):+ await stub.SampleData(SampleDataRequest(num_samples=50))++ print(+ f"Time taken: {time.time() - start}, {10000 / (time.time() - start)} samples/s"+ )+++async def serve():+ server = grpc.aio.server()+ add_DataServiceServicer_to_server(+ DataService(files=["data/quantized-dataset-1205.protos"]), server+ )+ listen_addr = "127.0.0.1:50051"+ server.add_insecure_port(listen_addr)+ print(f"Starting server on {listen_addr}")+ await server.start()+ await server.wait_for_termination()+++if __name__ == "__main__":+ # asyncio.run(serve())+ # Launch 14 workers++ asyncio.run(run())diff --git a/fish_speech/datasets/protos/text-data.proto b/fish_speech/datasets/protos/text-data.protoindex 219f2a0..9b30a11 100644--- a/fish_speech/datasets/protos/text-data.proto+++ b/fish_speech/datasets/protos/text-data.proto@@ -1,5 +1,7 @@syntax = "proto3";+package text_data;+message Semantics {repeated uint32 values = 1;}@@ -16,3 +18,15 @@ message TextData {repeated string languages = 3;repeated Sentence sentences = 4;}++message SampledData {+ repeated Sentence samples = 1;+}++message SampleDataRequest {+ uint32 num_samples = 1;+}++service DataService {+ rpc SampleData (SampleDataRequest) returns (SampledData) {}+}diff --git a/fish_speech/datasets/protos/text_data_pb2.py b/fish_speech/datasets/protos/text_data_pb2.pyindex 53fd306..8b1aa47 100644--- a/fish_speech/datasets/protos/text_data_pb2.py+++ b/fish_speech/datasets/protos/text_data_pb2.py@@ -1,7 +1,7 @@# -*- coding: utf-8 -*-# Generated by the protocol buffer compiler. DO NOT EDIT!# source: text-data.proto-# Protobuf Python Version: 4.25.1+# Protobuf Python Version: 4.25.0"""Generated protocol buffer code."""from google.protobuf import descriptor as _descriptorfrom google.protobuf import descriptor_pool as _descriptor_pool@@ -14,7 +14,7 @@ _sym_db = _symbol_database.Default()DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(- b'\n\x0ftext-data.proto"\x1b\n\tSemantics\x12\x0e\n\x06values\x18\x01 \x03(\r"G\n\x08Sentence\x12\x0c\n\x04text\x18\x01 \x01(\t\x12\x0e\n\x06phones\x18\x02 \x03(\t\x12\x1d\n\tsemantics\x18\x03 \x03(\x0b\x32\n.Semantics"Y\n\x08TextData\x12\x0e\n\x06source\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x11\n\tlanguages\x18\x03 \x03(\t\x12\x1c\n\tsentences\x18\x04 \x03(\x0b\x32\t.Sentenceb\x06proto3'+ b'\n\x0ftext-data.proto\x12\ttext_data"\x1b\n\tSemantics\x12\x0e\n\x06values\x18\x01 \x03(\r"Q\n\x08Sentence\x12\x0c\n\x04text\x18\x01 \x01(\t\x12\x0e\n\x06phones\x18\x02 \x03(\t\x12\'\n\tsemantics\x18\x03 \x03(\x0b\x32\x14.text_data.Semantics"c\n\x08TextData\x12\x0e\n\x06source\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x11\n\tlanguages\x18\x03 \x03(\t\x12&\n\tsentences\x18\x04 \x03(\x0b\x32\x13.text_data.Sentence"3\n\x0bSampledData\x12$\n\x07samples\x18\x01 \x03(\x0b\x32\x13.text_data.Sentence"(\n\x11SampleDataRequest\x12\x13\n\x0bnum_samples\x18\x01 \x01(\r2S\n\x0b\x44\x61taService\x12\x44\n\nSampleData\x12\x1c.text_data.SampleDataRequest\x1a\x16.text_data.SampledData"\x00\x62\x06proto3')_globals = globals()@@ -22,10 +22,16 @@ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "text_data_pb2", _globals)if _descriptor._USE_C_DESCRIPTORS == False:DESCRIPTOR._options = None- _globals["_SEMANTICS"]._serialized_start = 19- _globals["_SEMANTICS"]._serialized_end = 46- _globals["_SENTENCE"]._serialized_start = 48- _globals["_SENTENCE"]._serialized_end = 119- _globals["_TEXTDATA"]._serialized_start = 121- _globals["_TEXTDATA"]._serialized_end = 210+ _globals["_SEMANTICS"]._serialized_start = 30+ _globals["_SEMANTICS"]._serialized_end = 57+ _globals["_SENTENCE"]._serialized_start = 59+ _globals["_SENTENCE"]._serialized_end = 140+ _globals["_TEXTDATA"]._serialized_start = 142+ _globals["_TEXTDATA"]._serialized_end = 241+ _globals["_SAMPLEDDATA"]._serialized_start = 243+ _globals["_SAMPLEDDATA"]._serialized_end = 294+ _globals["_SAMPLEDATAREQUEST"]._serialized_start = 296+ _globals["_SAMPLEDATAREQUEST"]._serialized_end = 336+ _globals["_DATASERVICE"]._serialized_start = 338+ _globals["_DATASERVICE"]._serialized_end = 421# @@protoc_insertion_point(module_scope)diff --git a/fish_speech/datasets/protos/text_data_pb2_grpc.py b/fish_speech/datasets/protos/text_data_pb2_grpc.pynew file mode 100644index 0000000..e8bdf99--- /dev/null+++ b/fish_speech/datasets/protos/text_data_pb2_grpc.py@@ -0,0 +1,79 @@+# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!+"""Client and server classes corresponding to protobuf-defined services."""+import grpc++import fish_speech.datasets.protos.text_data_pb2 as text__data__pb2+++class DataServiceStub(object):+ """Missing associated documentation comment in .proto file."""++ def __init__(self, channel):+ """Constructor.++ Args:+ channel: A grpc.Channel.+ """+ self.SampleData = channel.unary_unary(+ "/text_data.DataService/SampleData",+ request_serializer=text__data__pb2.SampleDataRequest.SerializeToString,+ response_deserializer=text__data__pb2.SampledData.FromString,+ )+++class DataServiceServicer(object):+ """Missing associated documentation comment in .proto file."""++ def SampleData(self, request, context):+ """Missing associated documentation comment in .proto file."""+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)+ context.set_details("Method not implemented!")+ raise NotImplementedError("Method not implemented!")+++def add_DataServiceServicer_to_server(servicer, server):+ rpc_method_handlers = {+ "SampleData": grpc.unary_unary_rpc_method_handler(+ servicer.SampleData,+ request_deserializer=text__data__pb2.SampleDataRequest.FromString,+ response_serializer=text__data__pb2.SampledData.SerializeToString,+ ),+ }+ generic_handler = grpc.method_handlers_generic_handler(+ "text_data.DataService", rpc_method_handlers+ )+ server.add_generic_rpc_handlers((generic_handler,))+++# This class is part of an EXPERIMENTAL API.+class DataService(object):+ """Missing associated documentation comment in .proto file."""++ @staticmethod+ def SampleData(+ request,+ target,+ options=(),+ channel_credentials=None,+ call_credentials=None,+ insecure=False,+ compression=None,+ wait_for_ready=None,+ timeout=None,+ metadata=None,+ ):+ return grpc.experimental.unary_unary(+ request,+ target,+ "/text_data.DataService/SampleData",+ text__data__pb2.SampleDataRequest.SerializeToString,+ text__data__pb2.SampledData.FromString,+ options,+ channel_credentials,+ insecure,+ call_credentials,+ compression,+ wait_for_ready,+ timeout,+ metadata,+ )diff --git a/pyproject.toml b/pyproject.tomlindex 6d4c4c5..ba21221 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -33,6 +33,7 @@ dependencies = ["pyopenjtalk","wandb","tensorboard",+ "grpcio>=1.58.0"][build-system]