Download apps/readest-app/src-tauri/plugins/tauri-plugin-native-tts/src/lib.rs from echodict/readest: direct link, hf CLI and curl.
- Browser
- Download file 1.53 kB
-
https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src-tauri/plugins/tauri-plugin-native-tts/src/lib.rs
- Command line
-
hf download hf://datasets/echodict/readest/apps/readest-app/src-tauri/plugins/tauri-plugin-native-tts/src/lib.rs
-
curl -L -o lib.rs https://huggingface.co/datasets/echodict/readest/resolve/main/apps/readest-app/src-tauri/plugins/tauri-plugin-native-tts/src/lib.rs
1.53 kB
| use tauri::{ | |
| plugin::{Builder, TauriPlugin}, | |
| Manager, Runtime, | |
| }; | |
| pub use models::*; | |
| mod desktop; | |
| mod mobile; | |
| mod commands; | |
| mod error; | |
| mod models; | |
| pub use error::{Error, Result}; | |
| use desktop::NativeTts; | |
| use mobile::NativeTts; | |
| /// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the native-tts APIs. | |
| pub trait NativeTtsExt<R: Runtime> { | |
| fn native_tts(&self) -> &NativeTts<R>; | |
| } | |
| impl<R: Runtime, T: Manager<R>> crate::NativeTtsExt<R> for T { | |
| fn native_tts(&self) -> &NativeTts<R> { | |
| self.state::<NativeTts<R>>().inner() | |
| } | |
| } | |
| /// Initializes the plugin. | |
| pub fn init<R: Runtime>() -> TauriPlugin<R> { | |
| Builder::new("native-tts") | |
| .invoke_handler(tauri::generate_handler![ | |
| commands::init, | |
| commands::speak, | |
| commands::stop, | |
| commands::pause, | |
| commands::resume, | |
| commands::set_rate, | |
| commands::set_pitch, | |
| commands::set_voice, | |
| commands::get_all_voices, | |
| commands::set_media_session_active, | |
| commands::update_media_session_state, | |
| commands::update_media_session_metadata, | |
| ]) | |
| .setup(|app, api| { | |
| let native_tts = mobile::init(app, api)?; | |
| let native_tts = desktop::init(app, api)?; | |
| app.manage(native_tts); | |
| Ok(()) | |
| }) | |
| .build() | |
| } | |