diff --git a/crates/sbv2_core/src/jtalk.rs b/crates/sbv2_core/src/jtalk.rs index f73c159..205be8e 100644 --- a/crates/sbv2_core/src/jtalk.rs +++ b/crates/sbv2_core/src/jtalk.rs @@ -76,10 +76,7 @@ static MORA_PATTERN: Lazy> = Lazy::new(|| { }); static LONG_PATTERN: Lazy = Lazy::new(|| Regex::new(r"(\w)(ー*)").unwrap()); -fn phone_tone_to_kana( - phones: Vec, - tones: Vec, -) -> Vec<(String, i32)> { +fn phone_tone_to_kana(phones: Vec, tones: Vec) -> Vec<(String, i32)> { let phones = &phones[1..]; let tones = &tones[1..]; let mut results = Vec::new(); diff --git a/crates/sbv2_core/src/mora.rs b/crates/sbv2_core/src/mora.rs index dfe1ea8..4becd67 100644 --- a/crates/sbv2_core/src/mora.rs +++ b/crates/sbv2_core/src/mora.rs @@ -25,21 +25,20 @@ static MORA_LIST_ADDITIONAL: Lazy> = Lazy::new(|| { data.additional }); -pub static MORA_PHONEMES_TO_MORA_KATA: Lazy> = - 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> = 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, String)>> = Lazy::new(|| { diff --git a/crates/sbv2_editor/src/main.rs b/crates/sbv2_editor/src/main.rs index 7cc13f5..ac77598 100644 --- a/crates/sbv2_editor/src/main.rs +++ b/crates/sbv2_editor/src/main.rs @@ -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) -> AppResult>> { - let (normalized_text, process) = preprocess_parse_text(&request.text, &JTalk::new()?)?; +async fn create_audio_query( + Query(request): Query, +) -> AppResult { + 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::>(); + }) + .collect::>(); Ok(Json(response)) }