mirror of
https://github.com/lightsoutgames/godot-tts
synced 2024-12-28 03:45:57 +00:00
WIP: Try passing in utterance to signals.
This commit is contained in:
parent
a71bf417b6
commit
68d1d9e011
14
TTS.gd
14
TTS.gd
|
@ -1,9 +1,9 @@
|
|||
tool
|
||||
extends Node
|
||||
|
||||
signal utterance_begin
|
||||
signal utterance_begin(utterance)
|
||||
|
||||
signal utterance_end
|
||||
signal utterance_end(utterance)
|
||||
|
||||
var TTS
|
||||
|
||||
|
@ -235,12 +235,14 @@ func singular_or_plural(count, singular, plural):
|
|||
return plural
|
||||
|
||||
|
||||
func _on_utterance_begin():
|
||||
emit_signal("utterance_begin")
|
||||
func _on_utterance_begin(utterance):
|
||||
print("Here")
|
||||
print(utterance)
|
||||
emit_signal("utterance_begin", utterance)
|
||||
|
||||
|
||||
func _on_utterance_end():
|
||||
emit_signal("utterance_end")
|
||||
func _on_utterance_end(utterance):
|
||||
emit_signal("utterance_end", utterance)
|
||||
|
||||
|
||||
func _exit_tree():
|
||||
|
|
41
src/lib.rs
41
src/lib.rs
|
@ -3,6 +3,17 @@ use std::sync::mpsc::{channel, Receiver};
|
|||
use gdnative::prelude::*;
|
||||
use tts::{Features, UtteranceId, TTS as Tts};
|
||||
|
||||
#[derive(NativeClass)]
|
||||
#[inherit(Reference)]
|
||||
struct Utterance(pub(crate) Option<UtteranceId>);
|
||||
|
||||
#[methods]
|
||||
impl Utterance {
|
||||
fn new(_owner: &Reference) -> Self {
|
||||
Self(None)
|
||||
}
|
||||
}
|
||||
|
||||
enum Msg {
|
||||
UtteranceBegin(UtteranceId),
|
||||
UtteranceEnd(UtteranceId),
|
||||
|
@ -144,11 +155,21 @@ impl TTS {
|
|||
.done();
|
||||
builder.add_signal(Signal {
|
||||
name: "utterance_begin",
|
||||
args: &[],
|
||||
args: &[SignalArgument {
|
||||
name: "utterance",
|
||||
default: Variant::default(),
|
||||
export_info: ExportInfo::new(VariantType::Object),
|
||||
usage: PropertyUsage::DEFAULT,
|
||||
}],
|
||||
});
|
||||
builder.add_signal(Signal {
|
||||
name: "utterance_end",
|
||||
args: &[],
|
||||
args: &[SignalArgument {
|
||||
name: "utterance",
|
||||
default: Variant::default(),
|
||||
export_info: ExportInfo::new(VariantType::Object),
|
||||
usage: PropertyUsage::DEFAULT,
|
||||
}],
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -185,11 +206,19 @@ impl TTS {
|
|||
fn _process(&mut self, owner: &Node, _delta: f32) {
|
||||
if let Some(msg) = self.1.try_recv().ok() {
|
||||
match msg {
|
||||
Msg::UtteranceBegin(_utterance) => {
|
||||
owner.emit_signal("utterance_begin", &[]);
|
||||
Msg::UtteranceBegin(utterance_id) => {
|
||||
let utterance: Instance<Utterance, Unique> = Instance::new();
|
||||
/*utterance
|
||||
.map_mut(|u, _| u.0 = Some(utterance_id))
|
||||
.expect("Failed to set utterance ID");*/
|
||||
owner.emit_signal("utterance_begin", &[utterance.owned_to_variant()]);
|
||||
}
|
||||
Msg::UtteranceEnd(_utterance) => {
|
||||
owner.emit_signal("utterance_end", &[]);
|
||||
Msg::UtteranceEnd(utterance_id) => {
|
||||
let utterance: Instance<Utterance, Unique> = Instance::new();
|
||||
/*utterance
|
||||
.map_mut(|u, _| u.0 = Some(utterance_id))
|
||||
.expect("Failed to set utterance ID");*/
|
||||
owner.emit_signal("utterance_end", &[utterance.owned_to_variant()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user