mirror of
https://github.com/neodyland/sbv2-api.git
synced 2025-12-22 23:49:58 +00:00
refactor
This commit is contained in:
2
.github/workflows/CI.yml
vendored
2
.github/workflows/CI.yml
vendored
@@ -162,5 +162,5 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
ghcr.io/${{ github.repository }}:${{ matrix.tag }}
|
ghcr.io/${{ github.repository }}:${{ matrix.tag }}
|
||||||
file: docker/${{ matrix.tag }}.Dockerfile
|
file: scripts/docker/${{ matrix.tag }}.Dockerfile
|
||||||
platforms: ${{ matrix.platform }}
|
platforms: ${{ matrix.platform }}
|
||||||
|
|||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -5,4 +5,5 @@ venv/
|
|||||||
.env
|
.env
|
||||||
output.wav
|
output.wav
|
||||||
node_modules
|
node_modules
|
||||||
dist/
|
dist/
|
||||||
|
*.csv
|
||||||
815
Cargo.lock
generated
815
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
13
Cargo.toml
@@ -1,15 +1,16 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = ["sbv2_api", "sbv2_core", "sbv2_bindings", "sbv2_wasm"]
|
members = ["./crates/sbv2_api", "./crates/sbv2_core", "./crates/sbv2_bindings", "./crates/sbv2_wasm"]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
anyhow = "1.0.86"
|
anyhow = "1.0.96"
|
||||||
dotenvy = "0.15.7"
|
dotenvy = "0.15.7"
|
||||||
env_logger = "0.11.5"
|
env_logger = "0.11.6"
|
||||||
ndarray = "0.16.1"
|
ndarray = "0.16.1"
|
||||||
once_cell = "1.19.0"
|
once_cell = "1.20.3"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
|
||||||
debug = false
|
|
||||||
strip = true
|
strip = true
|
||||||
|
opt-level = "z"
|
||||||
|
lto = true
|
||||||
|
codegen-units = 1
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ JP-Extra しか対応していません。(基本的に対応する予定もあ
|
|||||||
|
|
||||||
## 変換方法
|
## 変換方法
|
||||||
|
|
||||||
[こちら](https://github.com/tuna2134/sbv2-api/tree/main/convert)を参照してください。
|
[こちら](https://github.com/tuna2134/sbv2-api/tree/main/scripts/convert)を参照してください。
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
|
|
||||||
@@ -119,3 +119,4 @@ curl http://localhost:3000/models
|
|||||||
|
|
||||||
- [litagin02/Style-Bert-VITS2](https://github.com/litagin02/Style-Bert-VITS2) - このコードの書くにあたり、ベースとなる部分を参考にさせていただきました。
|
- [litagin02/Style-Bert-VITS2](https://github.com/litagin02/Style-Bert-VITS2) - このコードの書くにあたり、ベースとなる部分を参考にさせていただきました。
|
||||||
- [Googlefan](https://github.com/Googlefan256) - 彼にモデルを ONNX ヘ変換および効率化をする方法を教わりました。
|
- [Googlefan](https://github.com/Googlefan256) - 彼にモデルを ONNX ヘ変換および効率化をする方法を教わりました。
|
||||||
|
- [Aivis Project](https://github.com/Aivis-Project/AivisSpeech-Engine) - 辞書部分
|
||||||
14
content.txt
14
content.txt
@@ -1,14 +0,0 @@
|
|||||||
悪徳貴族として名高いヴェレット家の長男――オウガ・ヴェレットは転生者である。
|
|
||||||
ブラック企業に勤め、過労死した彼には一つの夢があった。
|
|
||||||
|
|
||||||
「可愛いハーレム作って、美味い物を食べる。領民の税金で楽して好き放題な生活を送ってみせる!」
|
|
||||||
|
|
||||||
素晴らしき異世界ライフを夢見た彼は実現へ向けて、努力を始めた。
|
|
||||||
ハーレムを築くためにいじめられてる平民の子を助けて恩を売ってやったり。
|
|
||||||
労働力を手に入れるために多くの孤児を雇って教育したり。
|
|
||||||
反乱を起きても鎮圧できるように魔法学院へ通って魔法を極める。
|
|
||||||
|
|
||||||
「クックック……! 順調、順調! 未来は明るいなぁ!」
|
|
||||||
|
|
||||||
――オウガはまだ知らない。
|
|
||||||
楽な生活を送るためにしてきたことが評価され、世間から『聖者』様として呼ばれる未来を。
|
|
||||||
@@ -107,7 +107,7 @@ impl TTSModel {
|
|||||||
/// style_vector : StyleVector
|
/// style_vector : StyleVector
|
||||||
/// スタイルベクトル
|
/// スタイルベクトル
|
||||||
fn get_style_vector(
|
fn get_style_vector(
|
||||||
&self,
|
&mut self,
|
||||||
ident: String,
|
ident: String,
|
||||||
style_id: i32,
|
style_id: i32,
|
||||||
weight: f32,
|
weight: f32,
|
||||||
@@ -144,7 +144,7 @@ impl TTSModel {
|
|||||||
style_id: i32,
|
style_id: i32,
|
||||||
sdp_ratio: f32,
|
sdp_ratio: f32,
|
||||||
length_scale: f32,
|
length_scale: f32,
|
||||||
) -> anyhow::Result<Bound<PyBytes>> {
|
) -> anyhow::Result<Bound<'p, PyBytes>> {
|
||||||
let data = self.model.easy_synthesize(
|
let data = self.model.easy_synthesize(
|
||||||
ident.as_str(),
|
ident.as_str(),
|
||||||
&text,
|
&text,
|
||||||
@@ -13,17 +13,17 @@ anyhow.workspace = true
|
|||||||
dotenvy.workspace = true
|
dotenvy.workspace = true
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
hound = "3.5.1"
|
hound = "3.5.1"
|
||||||
jpreprocess = { version = "0.10.0", features = ["naist-jdic"] }
|
jpreprocess = { version = "0.12.0", features = ["naist-jdic"] }
|
||||||
ndarray.workspace = true
|
ndarray.workspace = true
|
||||||
num_cpus = "1.16.0"
|
num_cpus = "1.16.0"
|
||||||
once_cell.workspace = true
|
once_cell.workspace = true
|
||||||
ort = { git = "https://github.com/pykeio/ort.git", version = "2.0.0-rc.8", optional = true }
|
ort = { git = "https://github.com/pykeio/ort.git", version = "2.0.0-rc.9", optional = true }
|
||||||
regex = "1.10.6"
|
regex = "1.10.6"
|
||||||
serde = { version = "1.0.210", features = ["derive"] }
|
serde = { version = "1.0.210", features = ["derive"] }
|
||||||
serde_json = "1.0.128"
|
serde_json = "1.0.128"
|
||||||
tar = "0.4.41"
|
tar = "0.4.41"
|
||||||
thiserror = "1.0.63"
|
thiserror = "2.0.11"
|
||||||
tokenizers = { version = "0.20.0", default-features = false }
|
tokenizers = { version = "0.21.0", default-features = false }
|
||||||
zstd = "0.13.2"
|
zstd = "0.13.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
@@ -35,4 +35,4 @@ directml = ["ort/directml", "std"]
|
|||||||
tensorrt = ["ort/tensorrt", "std"]
|
tensorrt = ["ort/tensorrt", "std"]
|
||||||
coreml = ["ort/coreml", "std"]
|
coreml = ["ort/coreml", "std"]
|
||||||
default = ["std"]
|
default = ["std"]
|
||||||
no_std = ["tokenizers/unstable_wasm"]
|
no_std = ["tokenizers/unstable_wasm"]
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use ndarray::{Array2, Ix2};
|
use ndarray::{Array2, Ix2};
|
||||||
use ort::Session;
|
use ort::session::Session;
|
||||||
|
use ort::value::TensorRef;
|
||||||
|
|
||||||
pub fn predict(
|
pub fn predict(
|
||||||
session: &Session,
|
session: &mut Session,
|
||||||
token_ids: Vec<i64>,
|
token_ids: Vec<i64>,
|
||||||
attention_masks: Vec<i64>,
|
attention_masks: Vec<i64>,
|
||||||
) -> Result<Array2<f32>> {
|
) -> Result<Array2<f32>> {
|
||||||
let outputs = session.run(
|
let outputs = session.run(
|
||||||
ort::inputs! {
|
ort::inputs! {
|
||||||
"input_ids" => Array2::from_shape_vec((1, token_ids.len()), token_ids).unwrap(),
|
"input_ids" => TensorRef::from_array_view((vec![1, token_ids.len() as i64], token_ids.as_slice()))?,
|
||||||
"attention_mask" => Array2::from_shape_vec((1, attention_masks.len()), attention_masks).unwrap(),
|
"attention_mask" => TensorRef::from_array_view((vec![1, attention_masks.len() as i64], attention_masks.as_slice()))?,
|
||||||
}?
|
}
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let output = outputs["output"]
|
let output = outputs["output"]
|
||||||
@@ -6,6 +6,8 @@ pub enum Error {
|
|||||||
TokenizerError(#[from] tokenizers::Error),
|
TokenizerError(#[from] tokenizers::Error),
|
||||||
#[error("JPreprocess error: {0}")]
|
#[error("JPreprocess error: {0}")]
|
||||||
JPreprocessError(#[from] jpreprocess::error::JPreprocessError),
|
JPreprocessError(#[from] jpreprocess::error::JPreprocessError),
|
||||||
|
#[error("Lindera error: {0}")]
|
||||||
|
LinderaError(String),
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
#[error("ONNX error: {0}")]
|
#[error("ONNX error: {0}")]
|
||||||
OrtError(#[from] ort::Error),
|
OrtError(#[from] ort::Error),
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::mora::{MORA_KATA_TO_MORA_PHONEMES, VOWELS};
|
use crate::mora::{MORA_KATA_TO_MORA_PHONEMES, VOWELS};
|
||||||
use crate::norm::{replace_punctuation, PUNCTUATIONS};
|
use crate::norm::{replace_punctuation, PUNCTUATIONS};
|
||||||
use jpreprocess::*;
|
use jpreprocess::{kind, DefaultTokenizer, JPreprocess, SystemDictionaryConfig, UserDictionary};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use std::cmp::Reverse;
|
use std::cmp::Reverse;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
type JPreprocessType = JPreprocess<DefaultFetcher>;
|
type JPreprocessType = JPreprocess<DefaultTokenizer>;
|
||||||
|
|
||||||
fn initialize_jtalk() -> Result<JPreprocessType> {
|
fn initialize_jtalk() -> Result<JPreprocessType> {
|
||||||
let config = JPreprocessConfig {
|
let sdic =
|
||||||
dictionary: SystemDictionaryConfig::Bundled(kind::JPreprocessDictionaryKind::NaistJdic),
|
SystemDictionaryConfig::Bundled(kind::JPreprocessDictionaryKind::NaistJdic).load()?;
|
||||||
user_dictionary: None,
|
let u = UserDictionary::load(include_bytes!("./dic/all.dic/all.bin"))
|
||||||
};
|
.map_err(|e| Error::LinderaError(e.to_string()))?;
|
||||||
let jpreprocess = JPreprocess::from_config(config)?;
|
let jpreprocess = JPreprocess::with_dictionaries(sdic, Some(u));
|
||||||
Ok(jpreprocess)
|
Ok(jpreprocess)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ fn main_inner() -> anyhow::Result<()> {
|
|||||||
use sbv2_core::tts;
|
use sbv2_core::tts;
|
||||||
dotenvy::dotenv_override().ok();
|
dotenvy::dotenv_override().ok();
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
let text = fs::read_to_string("content.txt")?;
|
let text = "今日の天気は快晴です。";
|
||||||
let ident = "aaa";
|
let ident = "aaa";
|
||||||
let mut tts_holder = tts::TTSModelHolder::new(
|
let mut tts_holder = tts::TTSModelHolder::new(
|
||||||
&fs::read(env::var("BERT_MODEL_PATH")?)?,
|
&fs::read(env::var("BERT_MODEL_PATH")?)?,
|
||||||
101
crates/sbv2_core/src/model.rs
Normal file
101
crates/sbv2_core/src/model.rs
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
use crate::error::Result;
|
||||||
|
use ndarray::{array, Array1, Array2, Array3, Axis, Ix3};
|
||||||
|
use ort::session::{builder::GraphOptimizationLevel, Session};
|
||||||
|
|
||||||
|
#[allow(clippy::vec_init_then_push, unused_variables)]
|
||||||
|
pub fn load_model<P: AsRef<[u8]>>(model_file: P, bert: bool) -> Result<Session> {
|
||||||
|
let mut exp = Vec::new();
|
||||||
|
#[cfg(feature = "tensorrt")]
|
||||||
|
{
|
||||||
|
if bert {
|
||||||
|
exp.push(
|
||||||
|
ort::execution_providers::TensorRTExecutionProvider::default()
|
||||||
|
.with_fp16(true)
|
||||||
|
.with_profile_min_shapes("input_ids:1x1,attention_mask:1x1")
|
||||||
|
.with_profile_max_shapes("input_ids:1x100,attention_mask:1x100")
|
||||||
|
.with_profile_opt_shapes("input_ids:1x25,attention_mask:1x25")
|
||||||
|
.build(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(feature = "cuda")]
|
||||||
|
{
|
||||||
|
#[allow(unused_mut)]
|
||||||
|
let mut cuda = ort::execution_providers::CUDAExecutionProvider::default()
|
||||||
|
.with_conv_algorithm_search(
|
||||||
|
ort::execution_providers::CUDAExecutionProviderCuDNNConvAlgoSearch::Default,
|
||||||
|
);
|
||||||
|
#[cfg(feature = "cuda_tf32")]
|
||||||
|
{
|
||||||
|
cuda = cuda.with_tf32(true);
|
||||||
|
}
|
||||||
|
exp.push(cuda.build());
|
||||||
|
}
|
||||||
|
#[cfg(feature = "directml")]
|
||||||
|
{
|
||||||
|
exp.push(ort::execution_providers::DirectMLExecutionProvider::default().build());
|
||||||
|
}
|
||||||
|
#[cfg(feature = "coreml")]
|
||||||
|
{
|
||||||
|
exp.push(ort::execution_providers::CoreMLExecutionProvider::default().build());
|
||||||
|
}
|
||||||
|
exp.push(ort::execution_providers::CPUExecutionProvider::default().build());
|
||||||
|
Ok(Session::builder()?
|
||||||
|
.with_execution_providers(exp)?
|
||||||
|
.with_optimization_level(GraphOptimizationLevel::Level3)?
|
||||||
|
.with_intra_threads(num_cpus::get_physical())?
|
||||||
|
.with_parallel_execution(true)?
|
||||||
|
.with_inter_threads(num_cpus::get_physical())?
|
||||||
|
.commit_from_memory(model_file.as_ref())?)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
pub fn synthesize(
|
||||||
|
session: &mut Session,
|
||||||
|
bert_ori: Array2<f32>,
|
||||||
|
x_tst: Array1<i64>,
|
||||||
|
tones: Array1<i64>,
|
||||||
|
lang_ids: Array1<i64>,
|
||||||
|
style_vector: Array1<f32>,
|
||||||
|
sdp_ratio: f32,
|
||||||
|
length_scale: f32,
|
||||||
|
) -> Result<Array3<f32>> {
|
||||||
|
let bert_ori = bert_ori.insert_axis(Axis(0));
|
||||||
|
let bert_ori = bert_ori.as_standard_layout();
|
||||||
|
let bert = ort::value::TensorRef::from_array_view(&bert_ori)?;
|
||||||
|
let mut x_tst_lengths = array![x_tst.shape()[0] as i64];
|
||||||
|
let x_tst_lengths = ort::value::TensorRef::from_array_view(&mut x_tst_lengths)?;
|
||||||
|
let mut x_tst = x_tst.insert_axis(Axis(0));
|
||||||
|
let x_tst = ort::value::TensorRef::from_array_view(&mut x_tst)?;
|
||||||
|
let mut lang_ids = lang_ids.insert_axis(Axis(0));
|
||||||
|
let lang_ids = ort::value::TensorRef::from_array_view(&mut lang_ids)?;
|
||||||
|
let mut tones = tones.insert_axis(Axis(0));
|
||||||
|
let tones = ort::value::TensorRef::from_array_view(&mut tones)?;
|
||||||
|
let mut style_vector = style_vector.insert_axis(Axis(0));
|
||||||
|
let style_vector = ort::value::TensorRef::from_array_view(&mut style_vector)?;
|
||||||
|
let sid = vec![1_i64];
|
||||||
|
let sid = ort::value::TensorRef::from_array_view((vec![1_i64], sid.as_slice()))?;
|
||||||
|
let sdp_ratio = vec![sdp_ratio];
|
||||||
|
let sdp_ratio = ort::value::TensorRef::from_array_view((vec![1_i64], sdp_ratio.as_slice()))?;
|
||||||
|
let length_scale = vec![length_scale];
|
||||||
|
let length_scale =
|
||||||
|
ort::value::TensorRef::from_array_view((vec![1_i64], length_scale.as_slice()))?;
|
||||||
|
let outputs = session.run(ort::inputs! {
|
||||||
|
"x_tst" => x_tst,
|
||||||
|
"x_tst_lengths" => x_tst_lengths,
|
||||||
|
"sid" => sid,
|
||||||
|
"tones" => tones,
|
||||||
|
"language" => lang_ids,
|
||||||
|
"bert" => bert,
|
||||||
|
"style_vec" => style_vector,
|
||||||
|
"sdp_ratio" => sdp_ratio,
|
||||||
|
"length_scale" => length_scale,
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let audio_array = outputs["output"]
|
||||||
|
.try_extract_tensor::<f32>()?
|
||||||
|
.into_dimensionality::<Ix3>()?
|
||||||
|
.to_owned();
|
||||||
|
|
||||||
|
Ok(audio_array)
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::error::{Error, Result};
|
use crate::error::{Error, Result};
|
||||||
use crate::{jtalk, model, style, tokenizer, tts_util};
|
use crate::{jtalk, model, style, tokenizer, tts_util};
|
||||||
use ndarray::{concatenate, Array1, Array2, Array3, Axis};
|
use ndarray::{concatenate, Array1, Array2, Array3, Axis};
|
||||||
use ort::Session;
|
use ort::session::Session;
|
||||||
use tokenizers::Tokenizer;
|
use tokenizers::Tokenizer;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone)]
|
#[derive(PartialEq, Eq, Clone)]
|
||||||
@@ -147,7 +147,7 @@ impl TTSModelHolder {
|
|||||||
/// This function is for low-level usage, use `easy_synthesize` for high-level usage.
|
/// This function is for low-level usage, use `easy_synthesize` for high-level usage.
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pub fn parse_text(
|
pub fn parse_text(
|
||||||
&self,
|
&mut self,
|
||||||
text: &str,
|
text: &str,
|
||||||
) -> Result<(Array2<f32>, Array1<i64>, Array1<i64>, Array1<i64>)> {
|
) -> Result<(Array2<f32>, Array1<i64>, Array1<i64>, Array1<i64>)> {
|
||||||
crate::tts_util::parse_text_blocking(
|
crate::tts_util::parse_text_blocking(
|
||||||
@@ -155,15 +155,15 @@ impl TTSModelHolder {
|
|||||||
&self.jtalk,
|
&self.jtalk,
|
||||||
&self.tokenizer,
|
&self.tokenizer,
|
||||||
|token_ids, attention_masks| {
|
|token_ids, attention_masks| {
|
||||||
crate::bert::predict(&self.bert, token_ids, attention_masks)
|
crate::bert::predict(&mut self.bert, token_ids, attention_masks)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_model<I: Into<TTSIdent>>(&self, ident: I) -> Result<&TTSModel> {
|
fn find_model<I: Into<TTSIdent>>(&mut self, ident: I) -> Result<&mut TTSModel> {
|
||||||
let ident = ident.into();
|
let ident = ident.into();
|
||||||
self.models
|
self.models
|
||||||
.iter()
|
.iter_mut()
|
||||||
.find(|m| m.ident == ident)
|
.find(|m| m.ident == ident)
|
||||||
.ok_or(Error::ModelNotFoundError(ident.to_string()))
|
.ok_or(Error::ModelNotFoundError(ident.to_string()))
|
||||||
}
|
}
|
||||||
@@ -209,7 +209,7 @@ impl TTSModelHolder {
|
|||||||
/// # Note
|
/// # Note
|
||||||
/// This function is for low-level usage, use `easy_synthesize` for high-level usage.
|
/// This function is for low-level usage, use `easy_synthesize` for high-level usage.
|
||||||
pub fn get_style_vector<I: Into<TTSIdent>>(
|
pub fn get_style_vector<I: Into<TTSIdent>>(
|
||||||
&self,
|
&mut self,
|
||||||
ident: I,
|
ident: I,
|
||||||
style_id: i32,
|
style_id: i32,
|
||||||
weight: f32,
|
weight: f32,
|
||||||
@@ -232,11 +232,6 @@ impl TTSModelHolder {
|
|||||||
options: SynthesizeOptions,
|
options: SynthesizeOptions,
|
||||||
) -> Result<Vec<u8>> {
|
) -> Result<Vec<u8>> {
|
||||||
self.find_and_load_model(ident)?;
|
self.find_and_load_model(ident)?;
|
||||||
let vits2 = &self
|
|
||||||
.find_model(ident)?
|
|
||||||
.vits2
|
|
||||||
.as_ref()
|
|
||||||
.ok_or(Error::ModelNotFoundError(ident.into().to_string()))?;
|
|
||||||
let style_vector = self.get_style_vector(ident, style_id, options.style_weight)?;
|
let style_vector = self.get_style_vector(ident, style_id, options.style_weight)?;
|
||||||
let audio_array = if options.split_sentences {
|
let audio_array = if options.split_sentences {
|
||||||
let texts: Vec<&str> = text.split('\n').collect();
|
let texts: Vec<&str> = text.split('\n').collect();
|
||||||
@@ -246,8 +241,14 @@ impl TTSModelHolder {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let (bert_ori, phones, tones, lang_ids) = self.parse_text(t)?;
|
let (bert_ori, phones, tones, lang_ids) = self.parse_text(t)?;
|
||||||
|
|
||||||
|
let vits2 = self
|
||||||
|
.find_model(ident)?
|
||||||
|
.vits2
|
||||||
|
.as_mut()
|
||||||
|
.ok_or(Error::ModelNotFoundError(ident.into().to_string()))?;
|
||||||
let audio = model::synthesize(
|
let audio = model::synthesize(
|
||||||
&vits2,
|
vits2,
|
||||||
bert_ori.to_owned(),
|
bert_ori.to_owned(),
|
||||||
phones,
|
phones,
|
||||||
tones,
|
tones,
|
||||||
@@ -267,8 +268,14 @@ impl TTSModelHolder {
|
|||||||
)?
|
)?
|
||||||
} else {
|
} else {
|
||||||
let (bert_ori, phones, tones, lang_ids) = self.parse_text(text)?;
|
let (bert_ori, phones, tones, lang_ids) = self.parse_text(text)?;
|
||||||
|
|
||||||
|
let vits2 = self
|
||||||
|
.find_model(ident)?
|
||||||
|
.vits2
|
||||||
|
.as_mut()
|
||||||
|
.ok_or(Error::ModelNotFoundError(ident.into().to_string()))?;
|
||||||
model::synthesize(
|
model::synthesize(
|
||||||
&vits2,
|
vits2,
|
||||||
bert_ori.to_owned(),
|
bert_ori.to_owned(),
|
||||||
phones,
|
phones,
|
||||||
tones,
|
tones,
|
||||||
@@ -298,13 +305,13 @@ impl TTSModelHolder {
|
|||||||
length_scale: f32,
|
length_scale: f32,
|
||||||
) -> Result<Vec<u8>> {
|
) -> Result<Vec<u8>> {
|
||||||
self.find_and_load_model(ident)?;
|
self.find_and_load_model(ident)?;
|
||||||
let vits2 = &self
|
let vits2 = self
|
||||||
.find_model(ident)?
|
.find_model(ident)?
|
||||||
.vits2
|
.vits2
|
||||||
.as_ref()
|
.as_mut()
|
||||||
.ok_or(Error::ModelNotFoundError(ident.into().to_string()))?;
|
.ok_or(Error::ModelNotFoundError(ident.into().to_string()))?;
|
||||||
let audio_array = model::synthesize(
|
let audio_array = model::synthesize(
|
||||||
&vits2,
|
vits2,
|
||||||
bert_ori.to_owned(),
|
bert_ori.to_owned(),
|
||||||
phones,
|
phones,
|
||||||
tones,
|
tones,
|
||||||
@@ -13,7 +13,3 @@ once_cell.workspace = true
|
|||||||
js-sys = "0.3.70"
|
js-sys = "0.3.70"
|
||||||
ndarray.workspace = true
|
ndarray.workspace = true
|
||||||
wasm-bindgen-futures = "0.4.43"
|
wasm-bindgen-futures = "0.4.43"
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
lto = true
|
|
||||||
opt-level = "s"
|
|
||||||
5
crates/sbv2_wasm/build.sh
Executable file
5
crates/sbv2_wasm/build.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
wasm-pack build --target web sbv2_wasm
|
||||||
|
wasm-opt -O3 -o ./sbv2_wasm/pkg/sbv2_wasm_bg.wasm ./sbv2_wasm/pkg/sbv2_wasm_bg.wasm
|
||||||
|
wasm-strip ./sbv2_wasm/pkg/sbv2_wasm_bg.wasm
|
||||||
|
mkdir -p ./sbv2_wasm/dist
|
||||||
|
cp ./sbv2_wasm/sbv2_wasm/pkg/sbv2_wasm_bg.wasm ./sbv2_wasm/dist/sbv2_wasm_bg.wasm
|
||||||
@@ -13,13 +13,17 @@
|
|||||||
"author": "tuna2134",
|
"author": "tuna2134",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@biomejs/biome": "^1.9.2",
|
"@biomejs/biome": "^1.9.4",
|
||||||
"@types/node": "^22.7.4",
|
"@types/node": "^22.13.5",
|
||||||
"esbuild": "^0.24.0",
|
"esbuild": "^0.25.0",
|
||||||
"typescript": "^5.6.2"
|
"typescript": "^5.7.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"onnxruntime-web": "^1.19.2"
|
"onnxruntime-web": "^1.20.1"
|
||||||
},
|
},
|
||||||
"files": ["dist/*", "package.json", "README.md"]
|
"files": [
|
||||||
|
"dist/*",
|
||||||
|
"package.json",
|
||||||
|
"README.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
@@ -9,21 +9,21 @@ importers:
|
|||||||
.:
|
.:
|
||||||
dependencies:
|
dependencies:
|
||||||
onnxruntime-web:
|
onnxruntime-web:
|
||||||
specifier: ^1.19.2
|
specifier: ^1.20.1
|
||||||
version: 1.20.0
|
version: 1.20.1
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@biomejs/biome':
|
'@biomejs/biome':
|
||||||
specifier: ^1.9.2
|
specifier: ^1.9.4
|
||||||
version: 1.9.4
|
version: 1.9.4
|
||||||
'@types/node':
|
'@types/node':
|
||||||
specifier: ^22.7.4
|
specifier: ^22.13.5
|
||||||
version: 22.8.0
|
version: 22.13.5
|
||||||
esbuild:
|
esbuild:
|
||||||
specifier: ^0.24.0
|
specifier: ^0.25.0
|
||||||
version: 0.24.0
|
version: 0.25.0
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^5.6.2
|
specifier: ^5.7.3
|
||||||
version: 5.6.3
|
version: 5.7.3
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -80,146 +80,152 @@ packages:
|
|||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@esbuild/aix-ppc64@0.24.0':
|
'@esbuild/aix-ppc64@0.25.0':
|
||||||
resolution: {integrity: sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==}
|
resolution: {integrity: sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [ppc64]
|
cpu: [ppc64]
|
||||||
os: [aix]
|
os: [aix]
|
||||||
|
|
||||||
'@esbuild/android-arm64@0.24.0':
|
'@esbuild/android-arm64@0.25.0':
|
||||||
resolution: {integrity: sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==}
|
resolution: {integrity: sha512-grvv8WncGjDSyUBjN9yHXNt+cq0snxXbDxy5pJtzMKGmmpPxeAmAhWxXI+01lU5rwZomDgD3kJwulEnhTRUd6g==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [android]
|
os: [android]
|
||||||
|
|
||||||
'@esbuild/android-arm@0.24.0':
|
'@esbuild/android-arm@0.25.0':
|
||||||
resolution: {integrity: sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==}
|
resolution: {integrity: sha512-PTyWCYYiU0+1eJKmw21lWtC+d08JDZPQ5g+kFyxP0V+es6VPPSUhM6zk8iImp2jbV6GwjX4pap0JFbUQN65X1g==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [android]
|
os: [android]
|
||||||
|
|
||||||
'@esbuild/android-x64@0.24.0':
|
'@esbuild/android-x64@0.25.0':
|
||||||
resolution: {integrity: sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==}
|
resolution: {integrity: sha512-m/ix7SfKG5buCnxasr52+LI78SQ+wgdENi9CqyCXwjVR2X4Jkz+BpC3le3AoBPYTC9NHklwngVXvbJ9/Akhrfg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [android]
|
os: [android]
|
||||||
|
|
||||||
'@esbuild/darwin-arm64@0.24.0':
|
'@esbuild/darwin-arm64@0.25.0':
|
||||||
resolution: {integrity: sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==}
|
resolution: {integrity: sha512-mVwdUb5SRkPayVadIOI78K7aAnPamoeFR2bT5nszFUZ9P8UpK4ratOdYbZZXYSqPKMHfS1wdHCJk1P1EZpRdvw==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
'@esbuild/darwin-x64@0.24.0':
|
'@esbuild/darwin-x64@0.25.0':
|
||||||
resolution: {integrity: sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==}
|
resolution: {integrity: sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
|
|
||||||
'@esbuild/freebsd-arm64@0.24.0':
|
'@esbuild/freebsd-arm64@0.25.0':
|
||||||
resolution: {integrity: sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==}
|
resolution: {integrity: sha512-VN4ocxy6dxefN1MepBx/iD1dH5K8qNtNe227I0mnTRjry8tj5MRk4zprLEdG8WPyAPb93/e4pSgi1SoHdgOa4w==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
|
|
||||||
'@esbuild/freebsd-x64@0.24.0':
|
'@esbuild/freebsd-x64@0.25.0':
|
||||||
resolution: {integrity: sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==}
|
resolution: {integrity: sha512-mrSgt7lCh07FY+hDD1TxiTyIHyttn6vnjesnPoVDNmDfOmggTLXRv8Id5fNZey1gl/V2dyVK1VXXqVsQIiAk+A==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
|
|
||||||
'@esbuild/linux-arm64@0.24.0':
|
'@esbuild/linux-arm64@0.25.0':
|
||||||
resolution: {integrity: sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==}
|
resolution: {integrity: sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/linux-arm@0.24.0':
|
'@esbuild/linux-arm@0.25.0':
|
||||||
resolution: {integrity: sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==}
|
resolution: {integrity: sha512-vkB3IYj2IDo3g9xX7HqhPYxVkNQe8qTK55fraQyTzTX/fxaDtXiEnavv9geOsonh2Fd2RMB+i5cbhu2zMNWJwg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/linux-ia32@0.24.0':
|
'@esbuild/linux-ia32@0.25.0':
|
||||||
resolution: {integrity: sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==}
|
resolution: {integrity: sha512-43ET5bHbphBegyeqLb7I1eYn2P/JYGNmzzdidq/w0T8E2SsYL1U6un2NFROFRg1JZLTzdCoRomg8Rvf9M6W6Gg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/linux-loong64@0.24.0':
|
'@esbuild/linux-loong64@0.25.0':
|
||||||
resolution: {integrity: sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==}
|
resolution: {integrity: sha512-fC95c/xyNFueMhClxJmeRIj2yrSMdDfmqJnyOY4ZqsALkDrrKJfIg5NTMSzVBr5YW1jf+l7/cndBfP3MSDpoHw==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [loong64]
|
cpu: [loong64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/linux-mips64el@0.24.0':
|
'@esbuild/linux-mips64el@0.25.0':
|
||||||
resolution: {integrity: sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==}
|
resolution: {integrity: sha512-nkAMFju7KDW73T1DdH7glcyIptm95a7Le8irTQNO/qtkoyypZAnjchQgooFUDQhNAy4iu08N79W4T4pMBwhPwQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [mips64el]
|
cpu: [mips64el]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/linux-ppc64@0.24.0':
|
'@esbuild/linux-ppc64@0.25.0':
|
||||||
resolution: {integrity: sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==}
|
resolution: {integrity: sha512-NhyOejdhRGS8Iwv+KKR2zTq2PpysF9XqY+Zk77vQHqNbo/PwZCzB5/h7VGuREZm1fixhs4Q/qWRSi5zmAiO4Fw==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [ppc64]
|
cpu: [ppc64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/linux-riscv64@0.24.0':
|
'@esbuild/linux-riscv64@0.25.0':
|
||||||
resolution: {integrity: sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==}
|
resolution: {integrity: sha512-5S/rbP5OY+GHLC5qXp1y/Mx//e92L1YDqkiBbO9TQOvuFXM+iDqUNG5XopAnXoRH3FjIUDkeGcY1cgNvnXp/kA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [riscv64]
|
cpu: [riscv64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/linux-s390x@0.24.0':
|
'@esbuild/linux-s390x@0.25.0':
|
||||||
resolution: {integrity: sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==}
|
resolution: {integrity: sha512-XM2BFsEBz0Fw37V0zU4CXfcfuACMrppsMFKdYY2WuTS3yi8O1nFOhil/xhKTmE1nPmVyvQJjJivgDT+xh8pXJA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [s390x]
|
cpu: [s390x]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/linux-x64@0.24.0':
|
'@esbuild/linux-x64@0.25.0':
|
||||||
resolution: {integrity: sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==}
|
resolution: {integrity: sha512-9yl91rHw/cpwMCNytUDxwj2XjFpxML0y9HAOH9pNVQDpQrBxHy01Dx+vaMu0N1CKa/RzBD2hB4u//nfc+Sd3Cw==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
|
|
||||||
'@esbuild/netbsd-x64@0.24.0':
|
'@esbuild/netbsd-arm64@0.25.0':
|
||||||
resolution: {integrity: sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==}
|
resolution: {integrity: sha512-RuG4PSMPFfrkH6UwCAqBzauBWTygTvb1nxWasEJooGSJ/NwRw7b2HOwyRTQIU97Hq37l3npXoZGYMy3b3xYvPw==}
|
||||||
|
engines: {node: '>=18'}
|
||||||
|
cpu: [arm64]
|
||||||
|
os: [netbsd]
|
||||||
|
|
||||||
|
'@esbuild/netbsd-x64@0.25.0':
|
||||||
|
resolution: {integrity: sha512-jl+qisSB5jk01N5f7sPCsBENCOlPiS/xptD5yxOx2oqQfyourJwIKLRA2yqWdifj3owQZCL2sn6o08dBzZGQzA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [netbsd]
|
os: [netbsd]
|
||||||
|
|
||||||
'@esbuild/openbsd-arm64@0.24.0':
|
'@esbuild/openbsd-arm64@0.25.0':
|
||||||
resolution: {integrity: sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==}
|
resolution: {integrity: sha512-21sUNbq2r84YE+SJDfaQRvdgznTD8Xc0oc3p3iW/a1EVWeNj/SdUCbm5U0itZPQYRuRTW20fPMWMpcrciH2EJw==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [openbsd]
|
os: [openbsd]
|
||||||
|
|
||||||
'@esbuild/openbsd-x64@0.24.0':
|
'@esbuild/openbsd-x64@0.25.0':
|
||||||
resolution: {integrity: sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==}
|
resolution: {integrity: sha512-2gwwriSMPcCFRlPlKx3zLQhfN/2WjJ2NSlg5TKLQOJdV0mSxIcYNTMhk3H3ulL/cak+Xj0lY1Ym9ysDV1igceg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [openbsd]
|
os: [openbsd]
|
||||||
|
|
||||||
'@esbuild/sunos-x64@0.24.0':
|
'@esbuild/sunos-x64@0.25.0':
|
||||||
resolution: {integrity: sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==}
|
resolution: {integrity: sha512-bxI7ThgLzPrPz484/S9jLlvUAHYMzy6I0XiU1ZMeAEOBcS0VePBFxh1JjTQt3Xiat5b6Oh4x7UC7IwKQKIJRIg==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [sunos]
|
os: [sunos]
|
||||||
|
|
||||||
'@esbuild/win32-arm64@0.24.0':
|
'@esbuild/win32-arm64@0.25.0':
|
||||||
resolution: {integrity: sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==}
|
resolution: {integrity: sha512-ZUAc2YK6JW89xTbXvftxdnYy3m4iHIkDtK3CLce8wg8M2L+YZhIvO1DKpxrd0Yr59AeNNkTiic9YLf6FTtXWMw==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@esbuild/win32-ia32@0.24.0':
|
'@esbuild/win32-ia32@0.25.0':
|
||||||
resolution: {integrity: sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==}
|
resolution: {integrity: sha512-eSNxISBu8XweVEWG31/JzjkIGbGIJN/TrRoiSVZwZ6pkC6VX4Im/WV2cz559/TXLcYbcrDN8JtKgd9DJVIo8GA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
|
|
||||||
'@esbuild/win32-x64@0.24.0':
|
'@esbuild/win32-x64@0.25.0':
|
||||||
resolution: {integrity: sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==}
|
resolution: {integrity: sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
@@ -254,11 +260,11 @@ packages:
|
|||||||
'@protobufjs/utf8@1.1.0':
|
'@protobufjs/utf8@1.1.0':
|
||||||
resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==}
|
resolution: {integrity: sha512-Vvn3zZrhQZkkBE8LSuW3em98c0FwgO4nxzv6OdSxPKJIEKY2bGbHn+mhGIPerzI4twdxaP8/0+06HBpwf345Lw==}
|
||||||
|
|
||||||
'@types/node@22.8.0':
|
'@types/node@22.13.5':
|
||||||
resolution: {integrity: sha512-84rafSBHC/z1i1E3p0cJwKA+CfYDNSXX9WSZBRopjIzLET8oNt6ht2tei4C7izwDeEiLLfdeSVBv1egOH916hg==}
|
resolution: {integrity: sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg==}
|
||||||
|
|
||||||
esbuild@0.24.0:
|
esbuild@0.25.0:
|
||||||
resolution: {integrity: sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==}
|
resolution: {integrity: sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
@@ -268,14 +274,14 @@ packages:
|
|||||||
guid-typescript@1.0.9:
|
guid-typescript@1.0.9:
|
||||||
resolution: {integrity: sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==}
|
resolution: {integrity: sha512-Y8T4vYhEfwJOTbouREvG+3XDsjr8E3kIr7uf+JZ0BYloFsttiHU0WfvANVsR7TxNUJa/WpCnw/Ino/p+DeBhBQ==}
|
||||||
|
|
||||||
long@5.2.3:
|
long@5.3.1:
|
||||||
resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==}
|
resolution: {integrity: sha512-ka87Jz3gcx/I7Hal94xaN2tZEOPoUOEVftkQqZx2EeQRN7LGdfLlI3FvZ+7WDplm+vK2Urx9ULrvSowtdCieng==}
|
||||||
|
|
||||||
onnxruntime-common@1.20.0:
|
onnxruntime-common@1.20.1:
|
||||||
resolution: {integrity: sha512-9ehS4ul5fBszIcHhfxuDgk45lO+Fqrxmrgwk1Pxb1JRvbQiCB/v9Royv95SRCWHktLMviqNjBsEd/biJhd39cg==}
|
resolution: {integrity: sha512-YiU0s0IzYYC+gWvqD1HzLc46Du1sXpSiwzKb63PACIJr6LfL27VsXSXQvt68EzD3V0D5Bc0vyJTjmMxp0ylQiw==}
|
||||||
|
|
||||||
onnxruntime-web@1.20.0:
|
onnxruntime-web@1.20.1:
|
||||||
resolution: {integrity: sha512-IoUf8dqHFJLV4DUSz+Ok+xxyN6cQk57gb20m6PZE5gag3QXuvegYMq9dG8t/QF4JjTKIwvfvnr16ouzCCB9IMA==}
|
resolution: {integrity: sha512-TePF6XVpLL1rWVMIl5Y9ACBQcyCNFThZON/jgElNd9Txb73CIEGlklhYR3UEr1cp5r0rbGI6nDwwrs79g7WjoA==}
|
||||||
|
|
||||||
platform@1.3.6:
|
platform@1.3.6:
|
||||||
resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==}
|
resolution: {integrity: sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==}
|
||||||
@@ -284,13 +290,13 @@ packages:
|
|||||||
resolution: {integrity: sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==}
|
resolution: {integrity: sha512-mRUWCc3KUU4w1jU8sGxICXH/gNS94DvI1gxqDvBzhj1JpcsimQkYiOJfwsPUykUI5ZaspFbSgmBLER8IrQ3tqw==}
|
||||||
engines: {node: '>=12.0.0'}
|
engines: {node: '>=12.0.0'}
|
||||||
|
|
||||||
typescript@5.6.3:
|
typescript@5.7.3:
|
||||||
resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==}
|
resolution: {integrity: sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==}
|
||||||
engines: {node: '>=14.17'}
|
engines: {node: '>=14.17'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
undici-types@6.19.8:
|
undici-types@6.20.0:
|
||||||
resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}
|
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
|
|
||||||
@@ -329,76 +335,79 @@ snapshots:
|
|||||||
'@biomejs/cli-win32-x64@1.9.4':
|
'@biomejs/cli-win32-x64@1.9.4':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/aix-ppc64@0.24.0':
|
'@esbuild/aix-ppc64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/android-arm64@0.24.0':
|
'@esbuild/android-arm64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/android-arm@0.24.0':
|
'@esbuild/android-arm@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/android-x64@0.24.0':
|
'@esbuild/android-x64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/darwin-arm64@0.24.0':
|
'@esbuild/darwin-arm64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/darwin-x64@0.24.0':
|
'@esbuild/darwin-x64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/freebsd-arm64@0.24.0':
|
'@esbuild/freebsd-arm64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/freebsd-x64@0.24.0':
|
'@esbuild/freebsd-x64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-arm64@0.24.0':
|
'@esbuild/linux-arm64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-arm@0.24.0':
|
'@esbuild/linux-arm@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-ia32@0.24.0':
|
'@esbuild/linux-ia32@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-loong64@0.24.0':
|
'@esbuild/linux-loong64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-mips64el@0.24.0':
|
'@esbuild/linux-mips64el@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-ppc64@0.24.0':
|
'@esbuild/linux-ppc64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-riscv64@0.24.0':
|
'@esbuild/linux-riscv64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-s390x@0.24.0':
|
'@esbuild/linux-s390x@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/linux-x64@0.24.0':
|
'@esbuild/linux-x64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/netbsd-x64@0.24.0':
|
'@esbuild/netbsd-arm64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/openbsd-arm64@0.24.0':
|
'@esbuild/netbsd-x64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/openbsd-x64@0.24.0':
|
'@esbuild/openbsd-arm64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/sunos-x64@0.24.0':
|
'@esbuild/openbsd-x64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/win32-arm64@0.24.0':
|
'@esbuild/sunos-x64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/win32-ia32@0.24.0':
|
'@esbuild/win32-arm64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@esbuild/win32-x64@0.24.0':
|
'@esbuild/win32-ia32@0.25.0':
|
||||||
|
optional: true
|
||||||
|
|
||||||
|
'@esbuild/win32-x64@0.25.0':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@protobufjs/aspromise@1.1.2': {}
|
'@protobufjs/aspromise@1.1.2': {}
|
||||||
@@ -424,51 +433,52 @@ snapshots:
|
|||||||
|
|
||||||
'@protobufjs/utf8@1.1.0': {}
|
'@protobufjs/utf8@1.1.0': {}
|
||||||
|
|
||||||
'@types/node@22.8.0':
|
'@types/node@22.13.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types: 6.19.8
|
undici-types: 6.20.0
|
||||||
|
|
||||||
esbuild@0.24.0:
|
esbuild@0.25.0:
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@esbuild/aix-ppc64': 0.24.0
|
'@esbuild/aix-ppc64': 0.25.0
|
||||||
'@esbuild/android-arm': 0.24.0
|
'@esbuild/android-arm': 0.25.0
|
||||||
'@esbuild/android-arm64': 0.24.0
|
'@esbuild/android-arm64': 0.25.0
|
||||||
'@esbuild/android-x64': 0.24.0
|
'@esbuild/android-x64': 0.25.0
|
||||||
'@esbuild/darwin-arm64': 0.24.0
|
'@esbuild/darwin-arm64': 0.25.0
|
||||||
'@esbuild/darwin-x64': 0.24.0
|
'@esbuild/darwin-x64': 0.25.0
|
||||||
'@esbuild/freebsd-arm64': 0.24.0
|
'@esbuild/freebsd-arm64': 0.25.0
|
||||||
'@esbuild/freebsd-x64': 0.24.0
|
'@esbuild/freebsd-x64': 0.25.0
|
||||||
'@esbuild/linux-arm': 0.24.0
|
'@esbuild/linux-arm': 0.25.0
|
||||||
'@esbuild/linux-arm64': 0.24.0
|
'@esbuild/linux-arm64': 0.25.0
|
||||||
'@esbuild/linux-ia32': 0.24.0
|
'@esbuild/linux-ia32': 0.25.0
|
||||||
'@esbuild/linux-loong64': 0.24.0
|
'@esbuild/linux-loong64': 0.25.0
|
||||||
'@esbuild/linux-mips64el': 0.24.0
|
'@esbuild/linux-mips64el': 0.25.0
|
||||||
'@esbuild/linux-ppc64': 0.24.0
|
'@esbuild/linux-ppc64': 0.25.0
|
||||||
'@esbuild/linux-riscv64': 0.24.0
|
'@esbuild/linux-riscv64': 0.25.0
|
||||||
'@esbuild/linux-s390x': 0.24.0
|
'@esbuild/linux-s390x': 0.25.0
|
||||||
'@esbuild/linux-x64': 0.24.0
|
'@esbuild/linux-x64': 0.25.0
|
||||||
'@esbuild/netbsd-x64': 0.24.0
|
'@esbuild/netbsd-arm64': 0.25.0
|
||||||
'@esbuild/openbsd-arm64': 0.24.0
|
'@esbuild/netbsd-x64': 0.25.0
|
||||||
'@esbuild/openbsd-x64': 0.24.0
|
'@esbuild/openbsd-arm64': 0.25.0
|
||||||
'@esbuild/sunos-x64': 0.24.0
|
'@esbuild/openbsd-x64': 0.25.0
|
||||||
'@esbuild/win32-arm64': 0.24.0
|
'@esbuild/sunos-x64': 0.25.0
|
||||||
'@esbuild/win32-ia32': 0.24.0
|
'@esbuild/win32-arm64': 0.25.0
|
||||||
'@esbuild/win32-x64': 0.24.0
|
'@esbuild/win32-ia32': 0.25.0
|
||||||
|
'@esbuild/win32-x64': 0.25.0
|
||||||
|
|
||||||
flatbuffers@1.12.0: {}
|
flatbuffers@1.12.0: {}
|
||||||
|
|
||||||
guid-typescript@1.0.9: {}
|
guid-typescript@1.0.9: {}
|
||||||
|
|
||||||
long@5.2.3: {}
|
long@5.3.1: {}
|
||||||
|
|
||||||
onnxruntime-common@1.20.0: {}
|
onnxruntime-common@1.20.1: {}
|
||||||
|
|
||||||
onnxruntime-web@1.20.0:
|
onnxruntime-web@1.20.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
flatbuffers: 1.12.0
|
flatbuffers: 1.12.0
|
||||||
guid-typescript: 1.0.9
|
guid-typescript: 1.0.9
|
||||||
long: 5.2.3
|
long: 5.3.1
|
||||||
onnxruntime-common: 1.20.0
|
onnxruntime-common: 1.20.1
|
||||||
platform: 1.3.6
|
platform: 1.3.6
|
||||||
protobufjs: 7.4.0
|
protobufjs: 7.4.0
|
||||||
|
|
||||||
@@ -486,9 +496,9 @@ snapshots:
|
|||||||
'@protobufjs/path': 1.1.2
|
'@protobufjs/path': 1.1.2
|
||||||
'@protobufjs/pool': 1.1.0
|
'@protobufjs/pool': 1.1.0
|
||||||
'@protobufjs/utf8': 1.1.0
|
'@protobufjs/utf8': 1.1.0
|
||||||
'@types/node': 22.8.0
|
'@types/node': 22.13.5
|
||||||
long: 5.2.3
|
long: 5.3.1
|
||||||
|
|
||||||
typescript@5.6.3: {}
|
typescript@5.7.3: {}
|
||||||
|
|
||||||
undici-types@6.19.8: {}
|
undici-types@6.20.0: {}
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
use crate::error::Result;
|
|
||||||
use ndarray::{array, Array1, Array2, Array3, Axis, Ix3};
|
|
||||||
use ort::{GraphOptimizationLevel, Session};
|
|
||||||
|
|
||||||
#[allow(clippy::vec_init_then_push, unused_variables)]
|
|
||||||
pub fn load_model<P: AsRef<[u8]>>(model_file: P, bert: bool) -> Result<Session> {
|
|
||||||
let mut exp = Vec::new();
|
|
||||||
#[cfg(feature = "tensorrt")]
|
|
||||||
{
|
|
||||||
if bert {
|
|
||||||
exp.push(
|
|
||||||
ort::TensorRTExecutionProvider::default()
|
|
||||||
.with_fp16(true)
|
|
||||||
.with_profile_min_shapes("input_ids:1x1,attention_mask:1x1")
|
|
||||||
.with_profile_max_shapes("input_ids:1x100,attention_mask:1x100")
|
|
||||||
.with_profile_opt_shapes("input_ids:1x25,attention_mask:1x25")
|
|
||||||
.build(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(feature = "cuda")]
|
|
||||||
{
|
|
||||||
#[allow(unused_mut)]
|
|
||||||
let mut cuda = ort::CUDAExecutionProvider::default()
|
|
||||||
.with_conv_algorithm_search(ort::CUDAExecutionProviderCuDNNConvAlgoSearch::Default);
|
|
||||||
#[cfg(feature = "cuda_tf32")]
|
|
||||||
{
|
|
||||||
cuda = cuda.with_tf32(true);
|
|
||||||
}
|
|
||||||
exp.push(cuda.build());
|
|
||||||
}
|
|
||||||
#[cfg(feature = "directml")]
|
|
||||||
{
|
|
||||||
exp.push(ort::DirectMLExecutionProvider::default().build());
|
|
||||||
}
|
|
||||||
#[cfg(feature = "coreml")]
|
|
||||||
{
|
|
||||||
exp.push(ort::CoreMLExecutionProvider::default().build());
|
|
||||||
}
|
|
||||||
exp.push(ort::CPUExecutionProvider::default().build());
|
|
||||||
Ok(Session::builder()?
|
|
||||||
.with_execution_providers(exp)?
|
|
||||||
.with_optimization_level(GraphOptimizationLevel::Level3)?
|
|
||||||
.with_intra_threads(num_cpus::get_physical())?
|
|
||||||
.with_parallel_execution(true)?
|
|
||||||
.with_inter_threads(num_cpus::get_physical())?
|
|
||||||
.commit_from_memory(model_file.as_ref())?)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn synthesize(
|
|
||||||
session: &Session,
|
|
||||||
bert_ori: Array2<f32>,
|
|
||||||
x_tst: Array1<i64>,
|
|
||||||
tones: Array1<i64>,
|
|
||||||
lang_ids: Array1<i64>,
|
|
||||||
style_vector: Array1<f32>,
|
|
||||||
sdp_ratio: f32,
|
|
||||||
length_scale: f32,
|
|
||||||
) -> Result<Array3<f32>> {
|
|
||||||
let bert = bert_ori.insert_axis(Axis(0));
|
|
||||||
let x_tst_lengths: Array1<i64> = array![x_tst.shape()[0] as i64];
|
|
||||||
let x_tst = x_tst.insert_axis(Axis(0));
|
|
||||||
let lang_ids = lang_ids.insert_axis(Axis(0));
|
|
||||||
let tones = tones.insert_axis(Axis(0));
|
|
||||||
let style_vector = style_vector.insert_axis(Axis(0));
|
|
||||||
let outputs = session.run(ort::inputs! {
|
|
||||||
"x_tst" => x_tst,
|
|
||||||
"x_tst_lengths" => x_tst_lengths,
|
|
||||||
"sid" => array![0_i64],
|
|
||||||
"tones" => tones,
|
|
||||||
"language" => lang_ids,
|
|
||||||
"bert" => bert,
|
|
||||||
"style_vec" => style_vector,
|
|
||||||
"sdp_ratio" => array![sdp_ratio],
|
|
||||||
"length_scale" => array![length_scale],
|
|
||||||
}?)?;
|
|
||||||
|
|
||||||
let audio_array = outputs["output"]
|
|
||||||
.try_extract_tensor::<f32>()?
|
|
||||||
.into_dimensionality::<Ix3>()?
|
|
||||||
.to_owned();
|
|
||||||
|
|
||||||
Ok(audio_array)
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
wasm-pack build --target web sbv2_wasm
|
|
||||||
wasm-opt -O3 -o sbv2_wasm/pkg/sbv2_wasm_bg.wasm sbv2_wasm/pkg/sbv2_wasm_bg.wasm
|
|
||||||
mkdir -p sbv2_wasm/dist
|
|
||||||
cp sbv2_wasm/sbv2_wasm/pkg/sbv2_wasm_bg.wasm sbv2_wasm/dist/sbv2_wasm_bg.wasm
|
|
||||||
5
scripts/.gitignore
vendored
Normal file
5
scripts/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
*.json
|
||||||
|
venv/
|
||||||
|
tmp/
|
||||||
|
*.safetensors
|
||||||
|
*.npy
|
||||||
14
scripts/make_dict.sh
Executable file
14
scripts/make_dict.sh
Executable file
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
git clone https://github.com/Aivis-Project/AivisSpeech-Engine ./scripts/tmp --filter=blob:none -n
|
||||||
|
cd ./scripts/tmp
|
||||||
|
git checkout 168b2a1144afe300b0490d9a6dd773ec6e927667 -- resources/dictionaries/*.csv
|
||||||
|
cd ../..
|
||||||
|
rm -rf ./crates/sbv2_core/src/dic
|
||||||
|
cp -r ./scripts/tmp/resources/dictionaries ./crates/sbv2_core/src/dic
|
||||||
|
rm -rf ./scripts/tmp
|
||||||
|
for file in ./crates/sbv2_core/src/dic/0*.csv; do
|
||||||
|
/usr/bin/cat "$file"
|
||||||
|
echo
|
||||||
|
done > ./crates/sbv2_core/src/all.csv
|
||||||
|
lindera build ./crates/sbv2_core/src/all.csv ./crates/sbv2_core/src/dic/all.dic -u -k ipadic
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# 必要なパッケージのインストール\n",
|
"# 必要なパッケージのインストール\n",
|
||||||
"!pip install sbv2_bindings\n",
|
"%pip install sbv2_bindings\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# 必要なモジュールのインポート\n",
|
"# 必要なモジュールのインポート\n",
|
||||||
"import os\n",
|
"import os\n",
|
||||||
@@ -3,10 +3,10 @@ from sbv2_bindings import TTSModel
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Loading models...")
|
print("Loading models...")
|
||||||
model = TTSModel.from_path("../models/debert.onnx", "../models/tokenizer.json")
|
model = TTSModel.from_path("./models/debert.onnx", "./models/tokenizer.json")
|
||||||
print("Models loaded!")
|
print("Models loaded!")
|
||||||
|
|
||||||
model.load_sbv2file_from_path("amitaro", "../models/amitaro.sbv2")
|
model.load_sbv2file_from_path("amitaro", "./models/amitaro.sbv2")
|
||||||
print("All setup is done!")
|
print("All setup is done!")
|
||||||
|
|
||||||
style_vector = model.get_style_vector("amitaro", 0, 1.0)
|
style_vector = model.get_style_vector("amitaro", 0, 1.0)
|
||||||
Reference in New Issue
Block a user