mirror of
https://github.com/lightsoutgames/godot-tts
synced 2024-11-22 16:45:56 +00:00
Update Rust dependencies and get this thing actually working.
This commit is contained in:
parent
36278ca6ae
commit
b7b32e16a7
|
@ -2,15 +2,16 @@
|
||||||
name = "godot-tts"
|
name = "godot-tts"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gdnative = {git = "https://github.com/GodotNativeTools/godot-rust"}
|
gdnative = { path = "../godot-rust/gdnative" }
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
speech-dispatcher = "0.2"
|
speech-dispatcher = "0.3"
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
tolk = "0.1"
|
tolk = "0.1"
|
||||||
|
|
68
src/lib.rs
68
src/lib.rs
|
@ -1,49 +1,57 @@
|
||||||
#[macro_use]
|
use gdnative::*;
|
||||||
extern crate gdnative as godot;
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
extern crate speech_dispatcher;
|
|
||||||
#[cfg(windows)]
|
|
||||||
extern crate tolk;
|
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use speech_dispatcher::{Connection, Mode, Priority};
|
use speech_dispatcher::{Connection, Mode, Priority};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use tolk::Tolk;
|
use tolk::Tolk;
|
||||||
|
|
||||||
godot_class! {
|
#[derive(gdnative::NativeClass)]
|
||||||
class TTS: godot::Object {
|
#[inherit(gdnative::Node)]
|
||||||
fields {
|
struct TTS(
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
connection: Connection,
|
Connection,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
tolk: Tolk,
|
Tolk,
|
||||||
}
|
);
|
||||||
|
|
||||||
setup(_builder) {
|
#[methods]
|
||||||
}
|
impl TTS {
|
||||||
|
fn _init(_owner: gdnative::Node) -> Self {
|
||||||
constructor(header) {
|
|
||||||
TTS {
|
|
||||||
header,
|
|
||||||
#[cfg(unix)]
|
|
||||||
connection: Connection::open("godot", "godot", "godot", Mode::Single),
|
|
||||||
#[cfg(windows)]
|
|
||||||
tolk: Tolk::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export fn speak(&mut self) {
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
{
|
{
|
||||||
self.connection.say(Priority::Important, "Hello, world.".to_string());
|
let connection = Connection::open("godot", "godot", "godot", Mode::Single);
|
||||||
|
Self(connection)
|
||||||
}
|
}
|
||||||
|
#[cfg(windows)]
|
||||||
|
Self(Tolk::new())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[export]
|
||||||
|
fn speak(&mut self, _owner: Node, message: GodotString, interrupt: bool) {
|
||||||
|
let message = message.to_string();
|
||||||
|
println!("{}: {}", message, interrupt);
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
if interrupt {
|
||||||
|
self.0.cancel();
|
||||||
|
}
|
||||||
|
if message != "" {
|
||||||
|
self.0.say(Priority::Important, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(handle: godot::init::InitHandle) {
|
#[export]
|
||||||
TTS::register_class(handle);
|
fn stop(&mut self, _owner: Node) {
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
self.0.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn init(handle: gdnative::init::InitHandle) {
|
||||||
|
handle.add_class::<TTS>();
|
||||||
}
|
}
|
||||||
|
|
||||||
godot_gdnative_init!();
|
godot_gdnative_init!();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user