mirror of
https://github.com/neodyland/sbv2-api.git
synced 2025-12-27 17:42:57 +00:00
Compare commits
20 Commits
v0.1.x
...
v0.2.0-alp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
30e79d0df6 | ||
|
|
04c21aa97c | ||
|
|
6f388052ae | ||
|
|
04af3abad5 | ||
|
|
414e42db50 | ||
|
|
b8b0198ca8 | ||
|
|
a99fd39834 | ||
|
|
886ab78eeb | ||
|
|
c85f474dbf | ||
|
|
6d160d7ae8 | ||
|
|
ee927d65cb | ||
|
|
6e7d641ecb | ||
|
|
eb249aad81 | ||
|
|
f79a67138f | ||
|
|
09945e2c1c | ||
|
|
821b4c7fb3 | ||
|
|
ec06c35929 | ||
|
|
1373aef4b2 | ||
|
|
e2e49fd0e8 | ||
|
|
0cf9f87cc9 |
18
Cargo.lock
generated
18
Cargo.lock
generated
@@ -1819,7 +1819,7 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
|
||||
[[package]]
|
||||
name = "sbv2_api"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0-alpha"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"axum",
|
||||
@@ -1833,7 +1833,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sbv2_bindings"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0-alpha1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"ndarray",
|
||||
@@ -1843,7 +1843,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sbv2_core"
|
||||
version = "0.1.4"
|
||||
version = "0.2.0-alpha1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"dotenvy",
|
||||
@@ -2059,9 +2059,9 @@ checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
|
||||
|
||||
[[package]]
|
||||
name = "tar"
|
||||
version = "0.4.41"
|
||||
version = "0.4.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909"
|
||||
checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020"
|
||||
dependencies = [
|
||||
"filetime",
|
||||
"libc",
|
||||
@@ -2076,18 +2076,18 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.63"
|
||||
version = "1.0.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724"
|
||||
checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.63"
|
||||
version = "1.0.64"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261"
|
||||
checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
# SBV2-API
|
||||
|
||||
## 注意:本バージョンはアルファ版です。
|
||||
安定版を利用したい場合は[こちら](https://github.com/tuna2134/sbv2-api/tree/v0.1.x)をご覧ください。
|
||||
|
||||
## プログラミングに詳しくない方向け
|
||||
|
||||
[こちら](https://github.com/tuna2134/sbv2-gui?tab=readme-ov-file)を参照してください。
|
||||
|
||||
15
content.txt
15
content.txt
@@ -1 +1,14 @@
|
||||
10,000年前までコロナが流行っていました
|
||||
悪徳貴族として名高いヴェレット家の長男――オウガ・ヴェレットは転生者である。
|
||||
ブラック企業に勤め、過労死した彼には一つの夢があった。
|
||||
|
||||
「可愛いハーレム作って、美味い物を食べる。領民の税金で楽して好き放題な生活を送ってみせる!」
|
||||
|
||||
素晴らしき異世界ライフを夢見た彼は実現へ向けて、努力を始めた。
|
||||
ハーレムを築くためにいじめられてる平民の子を助けて恩を売ってやったり。
|
||||
労働力を手に入れるために多くの孤児を雇って教育したり。
|
||||
反乱を起きても鎮圧できるように魔法学院へ通って魔法を極める。
|
||||
|
||||
「クックック……! 順調、順調! 未来は明るいなぁ!」
|
||||
|
||||
――オウガはまだ知らない。
|
||||
楽な生活を送るためにしてきたことが評価され、世間から『聖者』様として呼ばれる未来を。
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "sbv2_api"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0-alpha"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
@@ -9,7 +9,7 @@ axum = "0.7.5"
|
||||
dotenvy.workspace = true
|
||||
env_logger.workspace = true
|
||||
log = "0.4.22"
|
||||
sbv2_core = { version = "0.1.3", path = "../sbv2_core" }
|
||||
sbv2_core = { version = "0.2.0-alpha", path = "../sbv2_core" }
|
||||
serde = { version = "1.0.210", features = ["derive"] }
|
||||
tokio = { version = "1.40.0", features = ["full"] }
|
||||
|
||||
|
||||
5
sbv2_api/build.rs
Normal file
5
sbv2_api/build.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
fn main() {
|
||||
if cfg!(feature = "coreml") {
|
||||
println!("cargo:rustc-link-arg=-fapple-link-rtlib");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "sbv2_bindings"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0-alpha1"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
@@ -12,4 +12,4 @@ crate-type = ["cdylib"]
|
||||
anyhow.workspace = true
|
||||
ndarray.workspace = true
|
||||
pyo3 = { version = "0.22.0", features = ["anyhow"] }
|
||||
sbv2_core = { version = "0.1.4", path = "../sbv2_core" }
|
||||
sbv2_core = { version = "0.2.0-alpha", path = "../sbv2_core" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::types::PyBytes;
|
||||
use sbv2_core::tts::{TTSModelHolder, SynthesizeOptions};
|
||||
use sbv2_core::tts::{SynthesizeOptions, TTSModelHolder};
|
||||
|
||||
use crate::style::StyleVector;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "sbv2_core"
|
||||
description = "Style-Bert-VITSの推論ライブラリ"
|
||||
version = "0.1.4"
|
||||
version = "0.2.0-alpha1"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
readme = "../README.md"
|
||||
|
||||
@@ -19,21 +19,6 @@ fn initialize_jtalk() -> Result<JPreprocessType> {
|
||||
Ok(jpreprocess)
|
||||
}
|
||||
|
||||
static JTALK_G2P_G_A1_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"/A:([0-9\-]+)\+").unwrap());
|
||||
static JTALK_G2P_G_A2_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"\+(\d+)\+").unwrap());
|
||||
static JTALK_G2P_G_A3_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"\+(\d+)/").unwrap());
|
||||
static JTALK_G2P_G_E3_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"!(\d+)_").unwrap());
|
||||
static JTALK_G2P_G_F1_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"/F:(\d+)_").unwrap());
|
||||
static JTALK_G2P_G_P3_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"\-(.*?)\+").unwrap());
|
||||
|
||||
fn numeric_feature_by_regex(regex: &Regex, text: &str) -> i32 {
|
||||
if let Some(mat) = regex.captures(text) {
|
||||
mat[1].parse::<i32>().unwrap()
|
||||
} else {
|
||||
-50
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! hash_set {
|
||||
($($elem:expr),* $(,)?) => {{
|
||||
let mut set = HashSet::new();
|
||||
@@ -239,7 +224,10 @@ impl JTalkProcess {
|
||||
}
|
||||
|
||||
fn kata_to_phoneme_list(mut text: String) -> Result<Vec<String>> {
|
||||
if PUNCTUATIONS.contains(&text.as_str()) {
|
||||
let chars: HashSet<String> = text.chars().map(|x| x.to_string()).collect();
|
||||
if chars.is_subset(&HashSet::from_iter(
|
||||
PUNCTUATIONS.iter().map(|x| x.to_string()),
|
||||
)) {
|
||||
return Ok(text.chars().map(|x| x.to_string()).collect());
|
||||
}
|
||||
if !KATAKANA_PATTERN.is_match(&text) {
|
||||
@@ -351,11 +339,7 @@ impl JTalkProcess {
|
||||
|
||||
let mut phones: Vec<String> = Vec::new();
|
||||
for (i, label) in labels.iter().enumerate() {
|
||||
let mut p3 = {
|
||||
let label_text = label.to_string();
|
||||
let mattched = JTALK_G2P_G_P3_PATTERN.captures(&label_text).unwrap();
|
||||
mattched[1].to_string()
|
||||
};
|
||||
let mut p3 = label.phoneme.c.clone().unwrap();
|
||||
if "AIUEO".contains(&p3) {
|
||||
// 文字をlowerする
|
||||
p3 = p3.to_lowercase();
|
||||
@@ -365,10 +349,10 @@ impl JTalkProcess {
|
||||
if i == 0 {
|
||||
phones.push("^".to_string());
|
||||
} else if i == labels.len() - 1 {
|
||||
let e3 = numeric_feature_by_regex(&JTALK_G2P_G_E3_PATTERN, &label.to_string());
|
||||
if e3 == 0 {
|
||||
let e3 = label.accent_phrase_prev.clone().unwrap().is_interrogative;
|
||||
if e3 {
|
||||
phones.push("$".to_string());
|
||||
} else if e3 == 1 {
|
||||
} else {
|
||||
phones.push("?".to_string());
|
||||
}
|
||||
}
|
||||
@@ -380,14 +364,33 @@ impl JTalkProcess {
|
||||
phones.push(p3.clone());
|
||||
}
|
||||
|
||||
let a1 = numeric_feature_by_regex(&JTALK_G2P_G_A1_PATTERN, &label.to_string());
|
||||
let a2 = numeric_feature_by_regex(&JTALK_G2P_G_A2_PATTERN, &label.to_string());
|
||||
let a3 = numeric_feature_by_regex(&JTALK_G2P_G_A3_PATTERN, &label.to_string());
|
||||
let a1 = if let Some(mora) = &label.mora {
|
||||
mora.relative_accent_position as i32
|
||||
} else {
|
||||
-50
|
||||
};
|
||||
let a2 = if let Some(mora) = &label.mora {
|
||||
mora.position_forward as i32
|
||||
} else {
|
||||
-50
|
||||
};
|
||||
let a3 = if let Some(mora) = &label.mora {
|
||||
mora.position_backward as i32
|
||||
} else {
|
||||
-50
|
||||
};
|
||||
|
||||
let f1 = numeric_feature_by_regex(&JTALK_G2P_G_F1_PATTERN, &label.to_string());
|
||||
let f1 = if let Some(accent_phrase) = &label.accent_phrase_curr {
|
||||
accent_phrase.mora_count as i32
|
||||
} else {
|
||||
-50
|
||||
};
|
||||
|
||||
let a2_next =
|
||||
numeric_feature_by_regex(&JTALK_G2P_G_A2_PATTERN, &labels[i + 1].to_string());
|
||||
let a2_next = if let Some(mora) = &labels[i + 1].mora {
|
||||
mora.position_forward as i32
|
||||
} else {
|
||||
-50
|
||||
};
|
||||
|
||||
if a3 == 1 && a2_next == 1 && "aeiouAEIOUNcl".contains(&p3) {
|
||||
phones.push("#".to_string());
|
||||
|
||||
Reference in New Issue
Block a user