fixes tool callong
This commit is contained in:
+39
-1
@@ -94,6 +94,16 @@ const PHRASES: &[Phrase] = &[
|
||||
|
||||
/// `GET /api/customvoice/phrases` — the reading phrases and the configured
|
||||
/// default language, used to populate the page's language selector.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/customvoice/phrases",
|
||||
tag = "customvoice",
|
||||
responses((
|
||||
status = 200,
|
||||
description = "The reading phrases (one per supported language) and the configured default language",
|
||||
body = crate::apidoc::PhrasesResponse,
|
||||
)),
|
||||
)]
|
||||
pub async fn phrases(State(state): State<AppState>) -> Json<Value> {
|
||||
let languages: Vec<Value> = PHRASES
|
||||
.iter()
|
||||
@@ -106,7 +116,8 @@ pub async fn phrases(State(state): State<AppState>) -> Json<Value> {
|
||||
}
|
||||
|
||||
/// Query string of `POST /api/customvoice`.
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, utoipa::IntoParams)]
|
||||
#[into_params(parameter_in = Query)]
|
||||
pub struct SetParams {
|
||||
/// ISO 639-1 code of the language the user recorded in.
|
||||
pub lang: String,
|
||||
@@ -120,6 +131,23 @@ pub struct SetParams {
|
||||
/// audio (a browser recording or an uploaded file; whatever container the
|
||||
/// client sent, ffmpeg probes the content). Transcodes it to a WAV reference,
|
||||
/// persists the transcript, and installs the voice for the running session.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/customvoice",
|
||||
tag = "customvoice",
|
||||
params(SetParams),
|
||||
request_body(
|
||||
content = String,
|
||||
content_type = "application/octet-stream",
|
||||
description = "Raw audio bytes: a browser recording (Opus/WebM) or an uploaded file (wav, mp3, m4a, ogg, flac…). ffmpeg probes the container.",
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Reference transcoded, persisted and installed as the active voice", body = crate::apidoc::SetVoiceResponse),
|
||||
(status = 400, description = "Unsupported language or empty body", body = crate::apidoc::ErrorResponse),
|
||||
(status = 500, description = "Could not create the directory or store the upload", body = crate::apidoc::ErrorResponse),
|
||||
(status = 502, description = "ffmpeg transcode failed", body = crate::apidoc::ErrorResponse),
|
||||
),
|
||||
)]
|
||||
pub async fn set_custom_voice(
|
||||
State(state): State<AppState>,
|
||||
Query(params): Query<SetParams>,
|
||||
@@ -202,6 +230,16 @@ pub async fn set_custom_voice(
|
||||
/// `POST /api/customvoice/clear` — drop the custom voice and restore the
|
||||
/// reference configured at startup (the `TTS_REFERENCE_AUDIO` voice), or no
|
||||
/// reference at all when none is configured.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/customvoice/clear",
|
||||
tag = "customvoice",
|
||||
responses((
|
||||
status = 200,
|
||||
description = "The configured reference is restored (or cleared when none is configured)",
|
||||
body = crate::apidoc::ClearResponse,
|
||||
)),
|
||||
)]
|
||||
pub async fn clear_custom_voice(State(state): State<AppState>) -> Json<Value> {
|
||||
match state.config.tts_reference() {
|
||||
Some((audio_path, text)) => {
|
||||
|
||||
Reference in New Issue
Block a user