mirror of
https://github.com/lightsoutgames/godot-tts
synced 2024-11-25 06:25: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
|
tool
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
signal utterance_begin
|
signal utterance_begin(utterance)
|
||||||
|
|
||||||
signal utterance_end
|
signal utterance_end(utterance)
|
||||||
|
|
||||||
var TTS
|
var TTS
|
||||||
|
|
||||||
|
@ -235,12 +235,14 @@ func singular_or_plural(count, singular, plural):
|
||||||
return plural
|
return plural
|
||||||
|
|
||||||
|
|
||||||
func _on_utterance_begin():
|
func _on_utterance_begin(utterance):
|
||||||
emit_signal("utterance_begin")
|
print("Here")
|
||||||
|
print(utterance)
|
||||||
|
emit_signal("utterance_begin", utterance)
|
||||||
|
|
||||||
|
|
||||||
func _on_utterance_end():
|
func _on_utterance_end(utterance):
|
||||||
emit_signal("utterance_end")
|
emit_signal("utterance_end", utterance)
|
||||||
|
|
||||||
|
|
||||||
func _exit_tree():
|
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 gdnative::prelude::*;
|
||||||
use tts::{Features, UtteranceId, TTS as Tts};
|
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 {
|
enum Msg {
|
||||||
UtteranceBegin(UtteranceId),
|
UtteranceBegin(UtteranceId),
|
||||||
UtteranceEnd(UtteranceId),
|
UtteranceEnd(UtteranceId),
|
||||||
|
@ -144,11 +155,21 @@ impl TTS {
|
||||||
.done();
|
.done();
|
||||||
builder.add_signal(Signal {
|
builder.add_signal(Signal {
|
||||||
name: "utterance_begin",
|
name: "utterance_begin",
|
||||||
args: &[],
|
args: &[SignalArgument {
|
||||||
|
name: "utterance",
|
||||||
|
default: Variant::default(),
|
||||||
|
export_info: ExportInfo::new(VariantType::Object),
|
||||||
|
usage: PropertyUsage::DEFAULT,
|
||||||
|
}],
|
||||||
});
|
});
|
||||||
builder.add_signal(Signal {
|
builder.add_signal(Signal {
|
||||||
name: "utterance_end",
|
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) {
|
fn _process(&mut self, owner: &Node, _delta: f32) {
|
||||||
if let Some(msg) = self.1.try_recv().ok() {
|
if let Some(msg) = self.1.try_recv().ok() {
|
||||||
match msg {
|
match msg {
|
||||||
Msg::UtteranceBegin(_utterance) => {
|
Msg::UtteranceBegin(utterance_id) => {
|
||||||
owner.emit_signal("utterance_begin", &[]);
|
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) => {
|
Msg::UtteranceEnd(utterance_id) => {
|
||||||
owner.emit_signal("utterance_end", &[]);
|
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