mirror of
https://github.com/neodyland/sbv2-api.git
synced 2025-12-22 23:49:58 +00:00
fix
This commit is contained in:
@@ -76,10 +76,7 @@ static MORA_PATTERN: Lazy<Vec<String>> = Lazy::new(|| {
|
||||
});
|
||||
static LONG_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\w)(ー*)").unwrap());
|
||||
|
||||
fn phone_tone_to_kana(
|
||||
phones: Vec<String>,
|
||||
tones: Vec<i32>,
|
||||
) -> Vec<(String, i32)> {
|
||||
fn phone_tone_to_kana(phones: Vec<String>, tones: Vec<i32>) -> Vec<(String, i32)> {
|
||||
let phones = &phones[1..];
|
||||
let tones = &tones[1..];
|
||||
let mut results = Vec::new();
|
||||
|
||||
@@ -25,21 +25,20 @@ static MORA_LIST_ADDITIONAL: Lazy<Vec<Mora>> = Lazy::new(|| {
|
||||
data.additional
|
||||
});
|
||||
|
||||
pub static MORA_PHONEMES_TO_MORA_KATA: Lazy<HashMap<String, String>> =
|
||||
Lazy::new(|| {
|
||||
let mut map = HashMap::new();
|
||||
for mora in MORA_LIST_MINIMUM.iter() {
|
||||
map.insert(
|
||||
format!(
|
||||
"{}{}",
|
||||
mora.consonant.clone().unwrap_or("".to_string()),
|
||||
mora.vowel
|
||||
),
|
||||
mora.mora.clone(),
|
||||
);
|
||||
}
|
||||
map
|
||||
});
|
||||
pub static MORA_PHONEMES_TO_MORA_KATA: Lazy<HashMap<String, String>> = Lazy::new(|| {
|
||||
let mut map = HashMap::new();
|
||||
for mora in MORA_LIST_MINIMUM.iter() {
|
||||
map.insert(
|
||||
format!(
|
||||
"{}{}",
|
||||
mora.consonant.clone().unwrap_or("".to_string()),
|
||||
mora.vowel
|
||||
),
|
||||
mora.mora.clone(),
|
||||
);
|
||||
}
|
||||
map
|
||||
});
|
||||
|
||||
pub static MORA_KATA_TO_MORA_PHONEMES: Lazy<HashMap<String, (Option<String>, String)>> =
|
||||
Lazy::new(|| {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use axum::{extract::Query, routing::get, Router, Json};
|
||||
use axum::{extract::Query, response::IntoResponse, routing::get, Json, Router};
|
||||
use sbv2_core::{jtalk::JTalk, tts_util::preprocess_parse_text};
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
use error::AppResult;
|
||||
@@ -12,21 +12,24 @@ struct RequestCreateAudioQuery {
|
||||
text: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Serialize)]
|
||||
struct ResponseCreateAudioQuery {
|
||||
kana: String,
|
||||
tone: i32,
|
||||
}
|
||||
|
||||
async fn create_audio_query(Query(request): Query<RequestCreateAudioQuery>) -> AppResult<Json<Vec<ResponseCreateAudioQuery>>> {
|
||||
let (normalized_text, process) = preprocess_parse_text(&request.text, &JTalk::new()?)?;
|
||||
async fn create_audio_query(
|
||||
Query(request): Query<RequestCreateAudioQuery>,
|
||||
) -> AppResult<impl IntoResponse> {
|
||||
let (_, process) = preprocess_parse_text(&request.text, &JTalk::new()?)?;
|
||||
let kana_tone_list = process.g2kana_tone()?;
|
||||
let response = kana_tone_list.iter().map(|(kana, tone)| {
|
||||
ResponseCreateAudioQuery {
|
||||
let response = kana_tone_list
|
||||
.iter()
|
||||
.map(|(kana, tone)| ResponseCreateAudioQuery {
|
||||
kana: kana.clone(),
|
||||
tone: *tone,
|
||||
}
|
||||
}).collect::<Vec<_>>();
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
Ok(Json(response))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user