mirror of
https://github.com/neodyland/sbv2-api.git
synced 2026-01-05 22:12:57 +00:00
環境変数で読み込むことにした
This commit is contained in:
@@ -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"] }
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user