mirror of
https://github.com/neodyland/sbv2-api.git
synced 2025-12-24 16:19:59 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be0370a2f9 | ||
|
|
ec3e412ca0 | ||
|
|
ccad71c564 | ||
|
|
b9ea462497 | ||
|
|
b21d425733 | ||
|
|
dc347fd5b3 | ||
|
|
d8d8c82deb | ||
|
|
e70b8e51d2 | ||
|
|
38f9d98d1a | ||
|
|
16725552bf | ||
|
|
24bb626282 | ||
|
|
cc1f704e0b | ||
|
|
d5b2c4842e | ||
|
|
46649fad18 | ||
|
|
9e4e098170 |
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: バグの報告
|
||||
about: バグを報告する場所です。
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**バグの説明**
|
||||
バグのエラーを張ってください
|
||||
|
||||
**再現する方法**
|
||||
どのようにバグが発生したか時系列でまとめてください。
|
||||
|
||||
**本来の挙動**
|
||||
本来動作すべきことについて簡潔にまとめてください。
|
||||
|
||||
**スクリーンショット**
|
||||
もしもあるならでいいです。
|
||||
|
||||
**端末の情報**
|
||||
- OS: [e.g. Linux]
|
||||
|
||||
**コード**
|
||||
```rs
|
||||
ここにコード貼ってください
|
||||
```
|
||||
17
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
17
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: 機能追加
|
||||
about: 機能追加してほしい場合これで作ってください。
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**機能追加の説明**
|
||||
ここで追加される機能の説明してください。
|
||||
|
||||
**メリット**
|
||||
ここにメリットを書いてください。
|
||||
|
||||
**デメリット**
|
||||
ここにデメリットを書いてください。
|
||||
8
Cargo.lock
generated
8
Cargo.lock
generated
@@ -77,9 +77,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.87"
|
||||
version = "1.0.89"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10f00e1f6e58a40e807377c75c6a7f97bf9044fab57816f2414e6f5f4499d7b8"
|
||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
@@ -1361,9 +1361,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.19.0"
|
||||
version = "1.20.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
||||
checksum = "33ea5043e58958ee56f3e15a90aee535795cd7dfd319846288d93c5b57d85cbe"
|
||||
|
||||
[[package]]
|
||||
name = "onig"
|
||||
|
||||
@@ -1,7 +1 @@
|
||||
日本語を母国語としない人々にとって、「日本語は非常に難しい言語である」と言われています。
|
||||
その理由として、
|
||||
・漢字、ひらがな、カタカナ、と表記が何種類もある。
|
||||
・同一の漢字でも音読みと訓読みがある
|
||||
・地名の読みが難しい
|
||||
・主語、述語が省略される
|
||||
などが挙げられます。
|
||||
10,000年前までコロナが流行っていました
|
||||
@@ -5,7 +5,7 @@ use axum::{
|
||||
routing::{get, post},
|
||||
Json, Router,
|
||||
};
|
||||
use sbv2_core::tts::TTSModelHolder;
|
||||
use sbv2_core::tts::{SynthesizeOptions, TTSModelHolder};
|
||||
use serde::Deserialize;
|
||||
use std::env;
|
||||
use std::sync::Arc;
|
||||
@@ -49,17 +49,15 @@ async fn synthesize(
|
||||
log::debug!("processing request: text={text}, ident={ident}, sdp_ratio={sdp_ratio}, length_scale={length_scale}");
|
||||
let buffer = {
|
||||
let tts_model = state.tts_model.lock().await;
|
||||
let (bert_ori, phones, tones, lang_ids) = tts_model.parse_text(&text)?;
|
||||
let style_vector = tts_model.get_style_vector(&ident, 0, 1.0)?;
|
||||
tts_model.synthesize(
|
||||
ident,
|
||||
bert_ori.to_owned(),
|
||||
phones,
|
||||
tones,
|
||||
lang_ids,
|
||||
style_vector,
|
||||
sdp_ratio,
|
||||
length_scale,
|
||||
tts_model.easy_synthesize(
|
||||
&ident,
|
||||
&text,
|
||||
0,
|
||||
SynthesizeOptions {
|
||||
sdp_ratio,
|
||||
length_scale,
|
||||
..Default::default()
|
||||
},
|
||||
)?
|
||||
};
|
||||
Ok(([(CONTENT_TYPE, "audio/wav")], buffer))
|
||||
|
||||
@@ -54,6 +54,17 @@ impl JTalk {
|
||||
Ok(Self { jpreprocess })
|
||||
}
|
||||
|
||||
pub fn num2word(&self, text: &str) -> Result<String> {
|
||||
let mut parsed = self.jpreprocess.text_to_njd(text)?;
|
||||
parsed.preprocess();
|
||||
let texts: Vec<String> = parsed
|
||||
.nodes
|
||||
.iter()
|
||||
.map(|x| x.get_string().to_string())
|
||||
.collect();
|
||||
Ok(texts.join(""))
|
||||
}
|
||||
|
||||
pub fn process_text(&self, text: &str) -> Result<JTalkProcess> {
|
||||
let parsed = self.jpreprocess.run_frontend(text)?;
|
||||
let jtalk_process = JTalkProcess::new(Arc::clone(&self.jpreprocess), parsed);
|
||||
|
||||
@@ -120,7 +120,8 @@ pub fn replace_punctuation(mut text: String) -> String {
|
||||
for (k, v) in REPLACE_MAP.iter() {
|
||||
text = text.replace(k, v);
|
||||
}
|
||||
PUNCTUATION_CLEANUP_PATTERN
|
||||
let content = PUNCTUATION_CLEANUP_PATTERN
|
||||
.replace_all(&text, "")
|
||||
.to_string()
|
||||
.to_string();
|
||||
content
|
||||
}
|
||||
|
||||
@@ -123,7 +123,8 @@ impl TTSModelHolder {
|
||||
&self,
|
||||
text: &str,
|
||||
) -> Result<(Array2<f32>, Array1<i64>, Array1<i64>, Array1<i64>)> {
|
||||
let normalized_text = norm::normalize_text(text);
|
||||
let text = self.jtalk.num2word(text)?;
|
||||
let normalized_text = norm::normalize_text(&text);
|
||||
|
||||
let process = self.jtalk.process_text(&normalized_text)?;
|
||||
let (phones, tones, mut word2ph) = process.g2p()?;
|
||||
@@ -301,10 +302,10 @@ impl TTSModelHolder {
|
||||
}
|
||||
|
||||
pub struct SynthesizeOptions {
|
||||
sdp_ratio: f32,
|
||||
length_scale: f32,
|
||||
style_weight: f32,
|
||||
split_sentences: bool,
|
||||
pub sdp_ratio: f32,
|
||||
pub length_scale: f32,
|
||||
pub style_weight: f32,
|
||||
pub split_sentences: bool,
|
||||
}
|
||||
|
||||
impl Default for SynthesizeOptions {
|
||||
|
||||
Reference in New Issue
Block a user