commit 7d9c3adc4c858d5c080f08cfe58f1e6beb8f0db4 Author: Nolan Darilek Date: Wed Jun 13 12:14:03 2018 +0000 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a821aa9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +/target +**/*.rs.bk +Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..5865a46 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "godot-tts" +version = "0.1.0" +authors = ["Nolan Darilek "] + +[lib] +crate-type = ["cdylib"] + +[dependencies] +gdnative = {git = "https://github.com/GodotNativeTools/godot-rust"} + +[target.'cfg(unix)'.dependencies] +speech-dispatcher = "0.2" + +[target.'cfg(windows)'.dependencies] +tolk = "0.1" diff --git a/godot_tts.gdnlib b/godot_tts.gdnlib new file mode 100644 index 0000000..695f4df --- /dev/null +++ b/godot_tts.gdnlib @@ -0,0 +1,14 @@ +[entry] + +X11.64="res://target/debug/libgodot_tts.so" + +[dependencies] + +X11.64=[ ] + +[general] + +singleton=false +load_once=true +symbol_prefix="godot_" +reloadable=true diff --git a/godot_tts.gdns b/godot_tts.gdns new file mode 100644 index 0000000..3856c1e --- /dev/null +++ b/godot_tts.gdns @@ -0,0 +1,9 @@ +[gd_resource type="NativeScript" load_steps=2 format=2] + +[ext_resource path="res://godot_tts.gdnlib" type="GDNativeLibrary" id=1] + +[resource] + +resource_name = "godot_tts" +class_name = "godot_tts" +library = ExtResource( 1 ) diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..31a6516 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,51 @@ +#[macro_use] +extern crate gdnative as godot; + +#[cfg(unix)] +extern crate speech_dispatcher; +#[cfg(windows)] +extern crate tolk; + +#[cfg(unix)] +use speech_dispatcher::{Connection, Mode, Priority}; +#[cfg(windows)] +use tolk::Tolk; + +godot_class! { + class TTS: godot::Object { + fields { + #[cfg(unix)] + connection: Connection, + #[cfg(windows)] + tolk: Tolk, + } + + setup(_builder) { + } + + 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)] + { + self.connection.say(Priority::Important, "Hello, world.".to_string()); + } + } + } +} + +fn init(handle: godot::init::InitHandle) { + TTS::register_class(handle); +} + +godot_gdnative_init!(); +godot_nativescript_init!(init); +godot_gdnative_terminate!();