Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/backend/gpt_sovits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ fn infer(speaker: &str, text: &str) -> Result<Vec<u8>, &'static str> {
}
}

#[allow(unused)]
#[derive(Debug, serde::Deserialize)]
pub struct SpeechRequest {
/// The text to generate audio for.
pub input: String,
/// Id of speaker.
#[serde(alias = "voice")]
pub speaker: String,

#[serde(default)]
pub response_format: String,
#[serde(default)]
pub speed: f32,
}

fn create_speech(speech_request: SpeechRequest) -> anyhow::Result<Vec<u8>> {
Expand Down
5 changes: 4 additions & 1 deletion src/backend/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ use crate::error;

use hyper::{Body, Request, Response};

#[cfg(all(feature = "piper", feature = "gpt_sovits"))]
compile_error!("Only one of the features 'piper' and 'gpt_sovits' can be enabled at a time.");

pub(crate) async fn handle_llama_request(req: Request<Body>) -> Response<Body> {
match req.uri().path() {
#[cfg(feature = "piper")]
"/v1/audio/speech" => piper::audio_speech_handler(req).await,
#[cfg(feature = "gpt_sovits")]
"/v1/audio/speech_gpt" => gpt_sovits::audio_speech_handler(req).await,
"/v1/audio/speech" => gpt_sovits::audio_speech_handler(req).await,
#[cfg(feature = "piper")]
"/v1/files" => piper::files_handler(req).await,
path => {
Expand Down