use tauri::{command, AppHandle, Runtime};
use crate::models::*;
use crate::Result;
use crate::TtsExt;
#[command]
pub(crate) async fn speak<R: Runtime>(
app: AppHandle<R>,
payload: SpeakRequest,
) -> Result<SpeakResponse> {
app.tts().speak(payload)
}
#[command]
pub(crate) async fn stop<R: Runtime>(app: AppHandle<R>) -> Result<StopResponse> {
app.tts().stop()
}
#[command]
pub(crate) async fn get_voices<R: Runtime>(
app: AppHandle<R>,
payload: GetVoicesRequest,
) -> Result<GetVoicesResponse> {
app.tts().get_voices(payload)
}
#[command]
pub(crate) async fn is_speaking<R: Runtime>(app: AppHandle<R>) -> Result<IsSpeakingResponse> {
app.tts().is_speaking()
}
#[command]
pub(crate) async fn is_initialized<R: Runtime>(app: AppHandle<R>) -> Result<IsInitializedResponse> {
app.tts().is_initialized()
}
#[command]
pub(crate) async fn pause_speaking<R: Runtime>(app: AppHandle<R>) -> Result<PauseResumeResponse> {
app.tts().pause_speaking()
}
#[command]
pub(crate) async fn resume_speaking<R: Runtime>(app: AppHandle<R>) -> Result<PauseResumeResponse> {
app.tts().resume_speaking()
}
#[command]
pub(crate) async fn preview_voice<R: Runtime>(
app: AppHandle<R>,
payload: PreviewVoiceRequest,
) -> Result<SpeakResponse> {
app.tts().preview_voice(payload)
}
#[command]
pub(crate) async fn register_listener<R: Runtime>(app: AppHandle<R>) -> Result<()> {
#[cfg(not(mobile))]
let _ = app;
#[cfg(mobile)]
{
let app_clone = app.clone();
app.tts().setup_event_relay(&app_clone)?;
}
Ok(())
}
#[command]
pub(crate) async fn set_background_behavior<R: Runtime>(
app: AppHandle<R>,
payload: SetBackgroundBehaviorRequest,
) -> Result<SetBackgroundBehaviorResponse> {
app.tts().set_background_behavior(payload)
}