mirror of https://github.com/ndarilek/tts-rs.git
Refactor to oxilangtag for language codes, and bump Windows dependency.
This commit is contained in:
parent
f5716c48f5
commit
22ae0ef5a3
|
@ -18,18 +18,18 @@ default = ["speech_dispatcher_0_11"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dyn-clonable = "0.9"
|
dyn-clonable = "0.9"
|
||||||
|
oxilangtag = "0.1"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
serde = { version = "1", optional = true, features = ["derive"] }
|
serde = { version = "1", optional = true, features = ["derive"] }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
unic-langid = "0.9.0"
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
tolk = { version = "0.5", optional = true }
|
tolk = { version = "0.5", optional = true }
|
||||||
windows = { version = "0.42", features = ["Foundation", "Foundation_Collections", "Media_Core", "Media_Playback", "Media_SpeechSynthesis", "Storage_Streams"] }
|
windows = { version = "0.43", features = ["Foundation", "Foundation_Collections", "Media_Core", "Media_Playback", "Media_SpeechSynthesis", "Storage_Streams"] }
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
speech-dispatcher = { version = "0.15", default-features = false }
|
speech-dispatcher = { version = "0.15", default-features = false }
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use std::{collections::HashMap, str::FromStr, sync::Mutex};
|
use std::{collections::HashMap, sync::Mutex};
|
||||||
|
|
||||||
use lazy_static::*;
|
use lazy_static::*;
|
||||||
use log::{info, trace};
|
use log::{info, trace};
|
||||||
|
use oxilangtag::LanguageTag;
|
||||||
use speech_dispatcher::*;
|
use speech_dispatcher::*;
|
||||||
use unic_langid::LanguageIdentifier;
|
|
||||||
|
|
||||||
use crate::{Backend, BackendId, Error, Features, UtteranceId, Voice, CALLBACKS};
|
use crate::{Backend, BackendId, Error, Features, UtteranceId, Voice, CALLBACKS};
|
||||||
|
|
||||||
|
@ -192,7 +192,7 @@ impl Backend for SpeechDispatcher {
|
||||||
id: v.name.clone(),
|
id: v.name.clone(),
|
||||||
name: v.name.clone(),
|
name: v.name.clone(),
|
||||||
gender: None,
|
gender: None,
|
||||||
language: LanguageIdentifier::from_str(&v.language).unwrap(),
|
language: LanguageTag::parse(v.language.clone()).unwrap(),
|
||||||
})
|
})
|
||||||
.collect::<Vec<Voice>>();
|
.collect::<Vec<Voice>>();
|
||||||
Ok(rv)
|
Ok(rv)
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use std::{str::FromStr, sync::Mutex};
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use log::{info, trace};
|
use log::{info, trace};
|
||||||
use unic_langid::LanguageIdentifier;
|
use oxilangtag::LanguageTag;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
use wasm_bindgen::JsCast;
|
use wasm_bindgen::JsCast;
|
||||||
use web_sys::{
|
use web_sys::{
|
||||||
|
@ -264,7 +264,7 @@ impl Drop for Web {
|
||||||
|
|
||||||
impl From<SpeechSynthesisVoice> for Voice {
|
impl From<SpeechSynthesisVoice> for Voice {
|
||||||
fn from(other: SpeechSynthesisVoice) -> Self {
|
fn from(other: SpeechSynthesisVoice) -> Self {
|
||||||
let language = LanguageIdentifier::from_str(&other.lang()).unwrap();
|
let language = LanguageTag::parse(other.lang()).unwrap();
|
||||||
Voice {
|
Voice {
|
||||||
id: other.voice_uri(),
|
id: other.voice_uri(),
|
||||||
name: other.name(),
|
name: other.name(),
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, VecDeque},
|
collections::{HashMap, VecDeque},
|
||||||
str::FromStr,
|
|
||||||
sync::Mutex,
|
sync::Mutex,
|
||||||
};
|
};
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use log::{info, trace};
|
use log::{info, trace};
|
||||||
use unic_langid::LanguageIdentifier;
|
use oxilangtag::LanguageTag;
|
||||||
use windows::{
|
use windows::{
|
||||||
Foundation::TypedEventHandler,
|
Foundation::TypedEventHandler,
|
||||||
Media::{
|
Media::{
|
||||||
|
@ -354,7 +353,7 @@ impl TryInto<Voice> for VoiceInformation {
|
||||||
Gender::Female
|
Gender::Female
|
||||||
};
|
};
|
||||||
let language: String = self.Language()?.try_into()?;
|
let language: String = self.Language()?.try_into()?;
|
||||||
let language = LanguageIdentifier::from_str(&language).unwrap();
|
let language = LanguageTag::parse(language).unwrap();
|
||||||
Ok(Voice {
|
Ok(Voice {
|
||||||
id: self.Id()?.try_into()?,
|
id: self.Id()?.try_into()?,
|
||||||
name: self.DisplayName()?.try_into()?,
|
name: self.DisplayName()?.try_into()?,
|
||||||
|
|
|
@ -22,6 +22,7 @@ use std::{boxed::Box, sync::RwLock};
|
||||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||||
use cocoa_foundation::base::id;
|
use cocoa_foundation::base::id;
|
||||||
use dyn_clonable::*;
|
use dyn_clonable::*;
|
||||||
|
pub use oxilangtag::LanguageTag;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use libc::c_char;
|
use libc::c_char;
|
||||||
|
@ -32,7 +33,6 @@ use speech_dispatcher::Error as SpeechDispatcherError;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
#[cfg(all(windows, feature = "tolk"))]
|
#[cfg(all(windows, feature = "tolk"))]
|
||||||
use tolk::Tolk;
|
use tolk::Tolk;
|
||||||
pub use unic_langid::LanguageIdentifier;
|
|
||||||
|
|
||||||
mod backends;
|
mod backends;
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ pub struct Voice {
|
||||||
pub(crate) id: String,
|
pub(crate) id: String,
|
||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
pub(crate) gender: Option<Gender>,
|
pub(crate) gender: Option<Gender>,
|
||||||
pub(crate) language: LanguageIdentifier,
|
pub(crate) language: LanguageTag<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Voice {
|
impl Voice {
|
||||||
|
@ -675,7 +675,7 @@ impl Voice {
|
||||||
self.gender
|
self.gender
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn language(&self) -> LanguageIdentifier {
|
pub fn language(&self) -> LanguageTag<String> {
|
||||||
self.language.clone()
|
self.language.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue