環境変数で読み込むことにした

This commit is contained in:
tuna2134
2024-09-10 09:40:49 +00:00
parent 30a5be0878
commit 3bbaf19e36
6 changed files with 16 additions and 5 deletions

View File

@@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
anyhow.workspace = true
axum = "0.7.5"
dotenvy = "0.15.7"
sbv2_core = { version = "0.1.0", path = "../sbv2_core" }
serde = { version = "1.0.210", features = ["derive"] }
tokio = { version = "1.40.0", features = ["full"] }

View File

@@ -7,6 +7,7 @@ use axum::{
};
use sbv2_core::tts::TTSModel;
use serde::Deserialize;
use std::env;
use std::sync::Arc;
use tokio::sync::Mutex;
@@ -28,9 +29,9 @@ async fn synthesize(
tts_model
} else {
*tts_model = Some(TTSModel::new(
"models/debert.onnx",
"models/model_opt.onnx",
"models/style_vectors.json",
env::var("BERT_MODEL_PATH")?,
env::var("MAIN_MODEL_PATH")?,
env::var("STYLE_VECTORS_PATH")?,
)?);
tts_model.as_ref().unwrap()
};
@@ -47,6 +48,7 @@ struct AppState {
#[tokio::main]
async fn main() -> anyhow::Result<()> {
dotenvy::dotenv().ok();
let app = Router::new()
.route("/", get(|| async { "Hello, World!" }))
.route("/synthesize", post(synthesize))