mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-11-01 00:09:37 +00:00
Merge branch 'master' into synthesize
This commit is contained in:
commit
9cd66c0358
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "tts"
|
name = "tts"
|
||||||
version = "0.22.4"
|
version = "0.23.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"
|
||||||
|
@ -28,7 +28,7 @@ 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.38", features = ["alloc", "Foundation", "Foundation_Collections", "Media_Core", "Media_Playback", "Media_SpeechSynthesis", "Storage_Streams"] }
|
windows = { version = "0.39", 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.13", default-features = false }
|
speech-dispatcher = { version = "0.13", default-features = false }
|
||||||
|
|
|
@ -86,7 +86,7 @@ impl WinRt {
|
||||||
backend_to_speech_synthesizer.insert(bid, synth.clone());
|
backend_to_speech_synthesizer.insert(bid, synth.clone());
|
||||||
drop(backend_to_speech_synthesizer);
|
drop(backend_to_speech_synthesizer);
|
||||||
let bid_clone = bid;
|
let bid_clone = bid;
|
||||||
player.MediaEnded(TypedEventHandler::new(
|
player.MediaEnded(&TypedEventHandler::new(
|
||||||
move |sender: &Option<MediaPlayer>, _args| {
|
move |sender: &Option<MediaPlayer>, _args| {
|
||||||
if let Some(sender) = sender {
|
if let Some(sender) = sender {
|
||||||
let backend_to_media_player = BACKEND_TO_MEDIA_PLAYER.lock().unwrap();
|
let backend_to_media_player = BACKEND_TO_MEDIA_PLAYER.lock().unwrap();
|
||||||
|
@ -110,14 +110,14 @@ impl WinRt {
|
||||||
tts.Options()?.SetSpeakingRate(utterance.rate.into())?;
|
tts.Options()?.SetSpeakingRate(utterance.rate.into())?;
|
||||||
tts.Options()?.SetAudioPitch(utterance.pitch.into())?;
|
tts.Options()?.SetAudioPitch(utterance.pitch.into())?;
|
||||||
tts.Options()?.SetAudioVolume(utterance.volume.into())?;
|
tts.Options()?.SetAudioVolume(utterance.volume.into())?;
|
||||||
tts.SetVoice(utterance.voice.clone())?;
|
tts.SetVoice(&utterance.voice)?;
|
||||||
let stream = tts
|
let text = &utterance.text;
|
||||||
.SynthesizeTextToStreamAsync(utterance.text.as_str())?
|
let stream =
|
||||||
.get()?;
|
tts.SynthesizeTextToStreamAsync(&text.into())?.get()?;
|
||||||
let content_type = stream.ContentType()?;
|
let content_type = stream.ContentType()?;
|
||||||
let source =
|
let source =
|
||||||
MediaSource::CreateFromStream(stream, content_type)?;
|
MediaSource::CreateFromStream(&stream, &content_type)?;
|
||||||
sender.SetSource(source)?;
|
sender.SetSource(&source)?;
|
||||||
sender.Play()?;
|
sender.Play()?;
|
||||||
if let Some(callback) = callbacks.utterance_begin.as_mut() {
|
if let Some(callback) = callbacks.utterance_begin.as_mut() {
|
||||||
callback(utterance.id);
|
callback(utterance.id);
|
||||||
|
@ -147,6 +147,7 @@ impl WinRt {
|
||||||
self.synth.Options()?.SetAudioPitch(self.pitch.into())?;
|
self.synth.Options()?.SetAudioPitch(self.pitch.into())?;
|
||||||
self.synth.Options()?.SetAudioVolume(self.volume.into())?;
|
self.synth.Options()?.SetAudioVolume(self.volume.into())?;
|
||||||
|
|
||||||
|
self.synth.SetVoice(&self.voice)?;
|
||||||
let synth_stream = self.synth.SynthesizeTextToStreamAsync(text)?.get()?;
|
let synth_stream = self.synth.SynthesizeTextToStreamAsync(text)?.get()?;
|
||||||
|
|
||||||
let size = synth_stream.Size()?;
|
let size = synth_stream.Size()?;
|
||||||
|
@ -347,7 +348,7 @@ impl Backend for WinRt {
|
||||||
for v in SpeechSynthesizer::AllVoices()? {
|
for v in SpeechSynthesizer::AllVoices()? {
|
||||||
let vid: String = v.Id()?.try_into()?;
|
let vid: String = v.Id()?.try_into()?;
|
||||||
if vid == voice.id {
|
if vid == voice.id {
|
||||||
self.voice = v.clone();
|
self.voice = v;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -650,13 +650,13 @@ impl Drop for Tts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub enum Gender {
|
pub enum Gender {
|
||||||
Male,
|
Male,
|
||||||
Female,
|
Female,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct Voice {
|
pub struct Voice {
|
||||||
pub(crate) id: String,
|
pub(crate) id: String,
|
||||||
pub(crate) name: String,
|
pub(crate) name: String,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user