Skip to content

Commit

Permalink
Fix: 起動直後は辞書が反映されないのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Nov 18, 2023
1 parent fbd9690 commit 1042543
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ mod voicevox;

use crate::aivoice::AIVOICE;
use crate::icon_manager::ICON_MANAGER;
use crate::routes::audio_query::OPEN_JTALK;
use crate::routes::user_dict::USER_DICT;

use anyhow::Result;
use axum::{
Expand Down Expand Up @@ -121,6 +123,11 @@ async fn main_impl(args: Cli) -> Result<()> {

info!("Starting server...");

{
let open_jtalk = OPEN_JTALK.lock().await;
let user_dict = USER_DICT.lock().await;
open_jtalk.use_user_dict(&user_dict)?;
}
info!("Listening on port {}", port);

axum::Server::bind(&addr)
Expand Down
4 changes: 2 additions & 2 deletions src/routes/user_dict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use tracing::warn;

use crate::error::{Error, Result};

static USER_DICT: Lazy<Arc<Mutex<UserDict>>> = Lazy::new(|| {
pub static USER_DICT: Lazy<Arc<Mutex<UserDict>>> = Lazy::new(|| {
let mut user_dict = UserDict::new();

if std::fs::metadata(&*USER_DICT_PATH).is_ok() {
Expand All @@ -21,7 +21,7 @@ static USER_DICT: Lazy<Arc<Mutex<UserDict>>> = Lazy::new(|| {
Arc::new(Mutex::new(user_dict))
});

static USER_DICT_PATH: Lazy<String> = Lazy::new(|| {
pub static USER_DICT_PATH: Lazy<String> = Lazy::new(|| {
process_path::get_executable_path()
.unwrap()
.parent()
Expand Down

0 comments on commit 1042543

Please sign in to comment.