mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00

* Implement TTS using windows crate * Use API calls instead of SSML * Properly stop player in case of TTS error * Add context to WindowsErrors * Validate available voices * Remove TTS text from synthesize error * Limit maximum buffer size * Make validation optional and list it in tts filter * We no longer need the winrt module (dae) * Use a separate request object so the meaning of the bool is clear (dae) * Slightly shorten runtime error message (dae) The default message appears to clip slightly. * Alternate buffer implementation (dae) * Use array instead of vec * Drop the max buffer size to 128k (dae)
32 lines
791 B
Rust
32 lines
791 B
Rust
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
use snafu::Snafu;
|
|
|
|
use super::AnkiError;
|
|
|
|
#[derive(Debug, PartialEq, Snafu)]
|
|
#[snafu(visibility(pub))]
|
|
pub struct WindowsError {
|
|
details: WindowsErrorDetails,
|
|
source: windows::core::Error,
|
|
}
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
pub enum WindowsErrorDetails {
|
|
SettingVoice(windows::Media::SpeechSynthesis::VoiceInformation),
|
|
SettingRate(f32),
|
|
Synthesizing,
|
|
Other,
|
|
}
|
|
|
|
impl From<windows::core::Error> for AnkiError {
|
|
fn from(source: windows::core::Error) -> Self {
|
|
AnkiError::WindowsError {
|
|
source: WindowsError {
|
|
source,
|
|
details: WindowsErrorDetails::Other,
|
|
},
|
|
}
|
|
}
|
|
}
|