Compare commits

...

11 Commits

6 changed files with 18 additions and 19 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "tts" name = "tts"
version = "0.24.3" version = "0.25.0"
authors = ["Nolan Darilek <nolan@thewordnerd.info>"] authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
repository = "https://github.com/ndarilek/tts-rs" repository = "https://github.com/ndarilek/tts-rs"
description = "High-level Text-To-Speech (TTS) interface" description = "High-level Text-To-Speech (TTS) interface"
@ -19,18 +19,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.10"
[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.16", default-features = false } speech-dispatcher = { version = "0.16", default-features = false }

View File

@ -1,5 +1,5 @@
#[cfg(any(target_os = "macos", target_os = "ios"))] #[cfg(any(target_os = "macos", target_os = "ios"))]
use std::{str::FromStr, sync::Mutex}; use std::sync::Mutex;
use cocoa_foundation::base::{id, nil, NO}; use cocoa_foundation::base::{id, nil, NO};
use cocoa_foundation::foundation::NSString; use cocoa_foundation::foundation::NSString;
@ -10,7 +10,7 @@ use lazy_static::lazy_static;
use log::{info, trace}; use log::{info, trace};
use objc::runtime::{Object, Sel}; use objc::runtime::{Object, Sel};
use objc::{class, declare::ClassDecl, msg_send, sel, sel_impl}; use objc::{class, declare::ClassDecl, msg_send, sel, sel_impl};
use unic_langid::LanguageIdentifier; use oxilangtag::LanguageTag;
use crate::{Backend, BackendId, Error, Features, Gender, UtteranceId, Voice, CALLBACKS}; use crate::{Backend, BackendId, Error, Features, Gender, UtteranceId, Voice, CALLBACKS};
@ -312,7 +312,7 @@ impl Backend for AvFoundation {
CFString::wrap_under_get_rule(msg_send![*v as *const Object, language]) CFString::wrap_under_get_rule(msg_send![*v as *const Object, language])
}; };
let language = language.to_string(); let language = language.to_string();
let language = LanguageIdentifier::from_str(&language).unwrap(); let language = LanguageTag::parse(language).unwrap();
Voice { Voice {
id: id.to_string(), id: id.to_string(),
name: name.to_string(), name: name.to_string(),

View File

@ -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)

View File

@ -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(),

View File

@ -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()?,

View File

@ -27,12 +27,12 @@ use lazy_static::lazy_static;
use libc::c_char; use libc::c_char;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
use objc::{class, msg_send, sel, sel_impl}; use objc::{class, msg_send, sel, sel_impl};
pub use oxilangtag::LanguageTag;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use speech_dispatcher::Error as SpeechDispatcherError; 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()
} }
} }