Skip to content

Commit

Permalink
Fix: CORS周りを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
sevenc-nanashi committed Sep 10, 2023
1 parent a2e1586 commit f760287
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/target

open_jtalk_dic_utf_8-1.11
*.vvpp
dist
19 changes: 19 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -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
12 changes: 1 addition & 11 deletions engine_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
}
12 changes: 6 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down
2 changes: 2 additions & 0 deletions src/routes/audio_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ pub struct AudioQuery {

pub static OPEN_JTALK: Lazy<Arc<Mutex<OpenJtalk>>> = 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) {
Expand Down
2 changes: 1 addition & 1 deletion src/routes/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit f760287

Please sign in to comment.