mirror of
https://github.com/neodyland/sbv2-api.git
synced 2025-12-22 23:49:58 +00:00
split the code for support voicevox
This commit is contained in:
@@ -5,6 +5,19 @@ use crate::{jtalk, nlp, norm, tokenizer, utils};
|
||||
use hound::{SampleFormat, WavSpec, WavWriter};
|
||||
use ndarray::{concatenate, s, Array, Array1, Array2, Array3, Axis};
|
||||
use tokenizers::Tokenizer;
|
||||
|
||||
pub fn preprocess_parse_text(
|
||||
text: &str,
|
||||
jtalk: &jtalk::JTalk,
|
||||
) -> Result<(Vec<String>, Vec<i32>, Vec<i32>)> {
|
||||
let text = jtalk.num2word(text)?;
|
||||
let normalized_text = norm::normalize_text(&text);
|
||||
|
||||
let process = jtalk.process_text(&normalized_text)?;
|
||||
let result = process.g2p()?;
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Parse text and return the input for synthesize
|
||||
///
|
||||
/// # Note
|
||||
@@ -21,11 +34,7 @@ pub async fn parse_text(
|
||||
Box<dyn std::future::Future<Output = Result<ndarray::Array2<f32>>>>,
|
||||
>,
|
||||
) -> Result<(Array2<f32>, Array1<i64>, Array1<i64>, Array1<i64>)> {
|
||||
let text = jtalk.num2word(text)?;
|
||||
let normalized_text = norm::normalize_text(&text);
|
||||
|
||||
let process = jtalk.process_text(&normalized_text)?;
|
||||
let (phones, tones, mut word2ph) = process.g2p()?;
|
||||
let (phones, tones, mut word2ph) = preprocess_parse_text(text, jtalk)?;
|
||||
let (phones, tones, lang_ids) = nlp::cleaned_text_to_sequence(phones, tones);
|
||||
|
||||
let phones = utils::intersperse(&phones, 0);
|
||||
|
||||
14
crates/sbv2_voicevox/Cargo.toml
Normal file
14
crates/sbv2_voicevox/Cargo.toml
Normal file
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "sbv2_voicevox"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
description.workspace = true
|
||||
license.workspace = true
|
||||
readme.workspace = true
|
||||
repository.workspace = true
|
||||
documentation.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
axum = "0.8.1"
|
||||
sbv2_core = { version = "0.2.0-alpha6", path = "../sbv2_core" }
|
||||
2
crates/sbv2_voicevox/README.md
Normal file
2
crates/sbv2_voicevox/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
# sbv2-voicevox
|
||||
sbv2-apiをvoicevox化します。
|
||||
5
crates/sbv2_voicevox/src/main.rs
Normal file
5
crates/sbv2_voicevox/src/main.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
println!("Hello, world!");
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user