chore: Update to Bevy 0.9 and TTS 0.25.

This commit is contained in:
Nolan Darilek 2022-12-06 13:22:26 -06:00
parent 678c56bfad
commit 10be842598
2 changed files with 11 additions and 5 deletions

View File

@ -11,17 +11,18 @@ edition = "2021"
[features] [features]
default = ["speech_dispatcher_0_11", "tolk"] default = ["speech_dispatcher_0_11", "tolk"]
speech_dispatcher_0_9 = ["tts/speech_dispatcher_0_9"]
speech_dispatcher_0_10 = ["tts/speech_dispatcher_0_10"] speech_dispatcher_0_10 = ["tts/speech_dispatcher_0_10"]
speech_dispatcher_0_11 = ["tts/speech_dispatcher_0_11"] speech_dispatcher_0_11 = ["tts/speech_dispatcher_0_11"]
tolk = ["tts/tolk"] tolk = ["tts/tolk"]
[dependencies] [dependencies]
bevy = { version = "0.8", default-features = false } bevy = { version = "0.9", default-features = false }
crossbeam-channel = "0.5" crossbeam-channel = "0.5"
tts = { version = "0.24", default-features = false } tts = { version = "0.25", default-features = false }
[dev-dependencies] [dev-dependencies]
bevy = { version = "0.8", default-features = true } bevy = { version = "0.9", default-features = true }
[package.metadata.release] [package.metadata.release]
tag-prefix = "" tag-prefix = ""

View File

@ -1,6 +1,9 @@
use bevy::prelude::*; use bevy::prelude::*;
use crossbeam_channel::{unbounded, Receiver}; use crossbeam_channel::{unbounded, Receiver};
pub use tts::{Backends, Error, Features, Tts, UtteranceId}; pub use tts::{Backends, Error, Features, UtteranceId};
#[derive(Resource, Clone, Deref, DerefMut)]
pub struct Tts(tts::Tts);
#[derive(Debug)] #[derive(Debug)]
pub enum TtsEvent { pub enum TtsEvent {
@ -9,6 +12,7 @@ pub enum TtsEvent {
UtteranceStop(UtteranceId), UtteranceStop(UtteranceId),
} }
#[derive(Resource)]
struct TtsChannel(Receiver<TtsEvent>); struct TtsChannel(Receiver<TtsEvent>);
fn poll_callbacks(channel: Res<TtsChannel>, mut events: EventWriter<TtsEvent>) { fn poll_callbacks(channel: Res<TtsChannel>, mut events: EventWriter<TtsEvent>) {
@ -21,7 +25,7 @@ pub struct TtsPlugin;
impl Plugin for TtsPlugin { impl Plugin for TtsPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
let tts = Tts::default().unwrap(); let tts = tts::Tts::default().unwrap();
let (tx, rx) = unbounded(); let (tx, rx) = unbounded();
let tx_begin = tx.clone(); let tx_begin = tx.clone();
let tx_end = tx.clone(); let tx_end = tx.clone();
@ -44,6 +48,7 @@ impl Plugin for TtsPlugin {
}))) })))
.unwrap(); .unwrap();
} }
let tts = Tts(tts);
app.add_event::<TtsEvent>() app.add_event::<TtsEvent>()
.insert_resource(TtsChannel(rx)) .insert_resource(TtsChannel(rx))
.insert_resource(tts) .insert_resource(tts)