Initial commit.

This commit is contained in:
Nolan Darilek 2018-06-13 12:14:03 +00:00
commit 7d9c3adc4c
5 changed files with 94 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/target
**/*.rs.bk
Cargo.lock

16
Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "godot-tts"
version = "0.1.0"
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
[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"

14
godot_tts.gdnlib Normal file
View File

@ -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

9
godot_tts.gdns Normal file
View File

@ -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 )

51
src/lib.rs Normal file
View File

@ -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!();