Fix build failure on Windows

This commit is contained in:
Damien Elmes 2023-06-12 15:51:00 +10:00
parent d380f3034c
commit 850e564a99
2 changed files with 11 additions and 15 deletions

View file

@ -21,7 +21,7 @@ const MAX_BUFFER_SIZE: usize = 128 * 1024;
pub(super) fn all_voices(validate: bool) -> Result<Vec<TtsVoice>> {
SpeechSynthesizer::AllVoices()?
.into_iter()
.map(|info| TtsVoice::from_voice_information(info, validate))
.map(|info| tts_voice_from_information(info, validate))
.collect()
}
@ -91,16 +91,14 @@ fn write_reader_to_file(reader: DataReader, file: &mut File, stream_size: usize)
Ok(())
}
impl TtsVoice {
fn from_voice_information(info: VoiceInformation, validate: bool) -> Result<Self> {
Ok(Self {
id: info.Id()?.to_string_lossy(),
name: info.DisplayName()?.to_string_lossy(),
language: info.Language()?.to_string_lossy(),
// Windows lists voices that fail when actually trying to use them. This has been
// observed with voices from an uninstalled language pack.
// Validation is optional because it may be slow.
available: validate.then(|| synthesize_stream(&info, 1.0, "").is_ok()),
})
}
fn tts_voice_from_information(info: VoiceInformation, validate: bool) -> Result<TtsVoice> {
Ok(TtsVoice {
id: info.Id()?.to_string_lossy(),
name: info.DisplayName()?.to_string_lossy(),
language: info.Language()?.to_string_lossy(),
// Windows lists voices that fail when actually trying to use them. This has been
// observed with voices from an uninstalled language pack.
// Validation is optional because it may be slow.
available: validate.then(|| synthesize_stream(&info, 1.0, "").is_ok()),
})
}

View file

@ -53,5 +53,3 @@ use lazy_static::lazy_static;
lazy_static! {
pub(crate) static ref PYTHON_UNIT_TESTS: bool = env::var("ANKI_TEST_MODE").is_ok();
}
// temporary during proto migration