add speakers list

This commit is contained in:
mii443
2025-04-27 17:10:45 +09:00
parent 8cc69404a4
commit 3a80d4769f
3 changed files with 33 additions and 1 deletions

View File

@ -1,4 +1,4 @@
use crate::types::audio_query::AudioQueryType;
use crate::types::{audio_query::AudioQueryType, speaker::Speaker};
use bytes::Bytes;
use reqwest::{header::HeaderMap, Client, RequestBuilder, Result};
@ -62,4 +62,14 @@ impl RestAPI {
.await?;
Ok(data)
}
pub async fn speakers(&self) -> Result<Vec<Speaker>> {
let speakers = self
.request("GET", "/speakers")
.send()
.await?
.json()
.await?;
Ok(speakers)
}
}

View File

@ -1 +1,2 @@
pub mod audio_query;
pub mod speaker;

21
src/types/speaker.rs Normal file
View File

@ -0,0 +1,21 @@
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Speaker {
pub supported_features: SupportedFeatures,
pub name: String,
pub speaker_uuid: String,
pub styles: Vec<Style>,
pub version: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct SupportedFeatures {
pub permitted_synthesis_morphing: String,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Style {
pub name: String,
pub id: i64,
}