From f76028794c4acb9c45d2c84a97b86236f8240623 Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Sun, 10 Sep 2023 22:19:34 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20CORS=E5=91=A8=E3=82=8A=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 ++ build.ps1 | 19 +++++++++++++++++++ engine_manifest.json | 12 +----------- src/main.rs | 12 ++++++------ src/routes/audio_query.rs | 2 ++ src/routes/info.rs | 2 +- 6 files changed, 31 insertions(+), 18 deletions(-) create mode 100644 build.ps1 diff --git a/.gitignore b/.gitignore index f9a18c4..77656ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target open_jtalk_dic_utf_8-1.11 +*.vvpp +dist diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..5b9d70e --- /dev/null +++ b/build.ps1 @@ -0,0 +1,19 @@ +cargo build -r + +if (Test-Path -Path "dist") { + Remove-Item -Path "dist" -Recurse -Force +} + +New-Item -Path "dist" -ItemType "directory" + +Copy-Item -Path "target/release/aivoice-vox.exe" -Destination "dist/aivoice-vox.exe" -Force + +Copy-Item -Path ./open_jtalk_dic_utf_8-1.11 ./dist/open_jtalk_dic_utf_8-1.11 -Recurse -Force +Copy-Item -Path ./README.md -Destination ./dist/README.md +Copy-Item -Path ./engine_manifest.json -Destination ./dist/engine_manifest.json + +Set-Location -Path "dist" + +Compress-Archive -Path * -DestinationPath "../aivoice-vox.zip" -Force +cd .. +Move-Item -Path "./aivoice-vox.zip" -Destination "./aivoice-vox.vvpp" -Force diff --git a/engine_manifest.json b/engine_manifest.json index e7eb436..0a56bd5 100644 --- a/engine_manifest.json +++ b/engine_manifest.json @@ -3,15 +3,5 @@ "uuid": "14f4bd0b-99ac-48cc-8171-d93439f16b33", "command": "aivoice-vox", "port": 50201, - "supported_features": { - "adjust_mora_pitch": false, - "adjust_phoneme_length": false, - "adjust_speed_scale": true, - "adjust_pitch_scale": true, - "adjust_intonation_scale": true, - "adjust_volume_scale": true, - "interrogative_upspeak": false, - "synthesis_morphing": false, - "manage_library": false - } + "supported_features": {} } diff --git a/src/main.rs b/src/main.rs index 05c6cc4..4d4b028 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,17 +61,17 @@ async fn main() -> Result<()> { post(routes::audio_query::post_accent_phrases), ) .route("/synthesis", post(routes::synthesis::post_synthesis)) + .layer(CorsLayer::permissive()) .layer( trace::TraceLayer::new_for_http() .make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO)) .on_response(trace::DefaultOnResponse::new().level(Level::INFO)), - ) - .layer(CorsLayer::permissive().allow_origin([ - "app://".parse().unwrap(), - "http://localhost:5173".parse().unwrap(), - ])); + ); - tracing_subscriber::fmt().init(); + tracing_subscriber::fmt() + .with_writer(std::io::stderr) + .with_ansi(cfg!(debug_assertions)) + .init(); AIVOICE.lock().await.setup().await?; diff --git a/src/routes/audio_query.rs b/src/routes/audio_query.rs index 97c639d..5cb900e 100644 --- a/src/routes/audio_query.rs +++ b/src/routes/audio_query.rs @@ -32,6 +32,8 @@ pub struct AudioQuery { pub static OPEN_JTALK: Lazy>> = Lazy::new(|| { let path = process_path::get_executable_path() + .unwrap() + .parent() .unwrap() .join("open_jtalk_dic_utf_8-1.11"); let open_jtalk = OpenJtalk::new_with_initialize(if cfg!(debug_assertions) { diff --git a/src/routes/info.rs b/src/routes/info.rs index d6f6e12..a97a992 100644 --- a/src/routes/info.rs +++ b/src/routes/info.rs @@ -67,7 +67,7 @@ pub struct SupportedDeveices { pub async fn get_version() -> impl IntoResponse { if let Ok(version) = AIVOICE.lock().await.version().await { - format!("{} ({})", env!("CARGO_PKG_VERSION"), version).into_response() + Json(format!("{} ({})", env!("CARGO_PKG_VERSION"), version)).into_response() } else { (StatusCode::INTERNAL_SERVER_ERROR, "Failed to get version").into_response() }