Clippy, fmt, bump versions, and update repository links.
This commit is contained in:
parent
cb02834873
commit
369bf23fa9
|
@ -1,8 +1,8 @@
|
||||||
[package]
|
[package]
|
||||||
name = "speech-dispatcher-sys"
|
name = "speech-dispatcher-sys"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
||||||
repository = "https://gitlab.com/ndarilek/speech-dispatcher-sys"
|
repository = "https://gitlab.com/ndarilek/speech-dispatcher-rs"
|
||||||
description = "speech-dispatcher system bindings"
|
description = "speech-dispatcher system bindings"
|
||||||
license = "LGPL-2.1"
|
license = "LGPL-2.1"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "speech-dispatcher"
|
name = "speech-dispatcher"
|
||||||
version = "0.4.1"
|
version = "0.4.2"
|
||||||
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
||||||
repository = "https://gitlab.com/ndarilek/speech-dispatcher-rs"
|
repository = "https://gitlab.com/ndarilek/speech-dispatcher-rs"
|
||||||
description = "Rusty interface to the speech-dispatcher speech synthesis library"
|
description = "Rusty interface to the speech-dispatcher speech synthesis library"
|
||||||
|
|
|
@ -3,8 +3,16 @@ extern crate speech_dispatcher;
|
||||||
use speech_dispatcher::*;
|
use speech_dispatcher::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let connection = speech_dispatcher::Connection::open("hello_world", "hello_world", "hello_world", Mode::Single);
|
let connection = speech_dispatcher::Connection::open(
|
||||||
connection.say(Priority::Important, format!("Hello, world at rate {}.", connection.get_voice_rate()));
|
"hello_world",
|
||||||
|
"hello_world",
|
||||||
|
"hello_world",
|
||||||
|
Mode::Single,
|
||||||
|
);
|
||||||
|
connection.say(
|
||||||
|
Priority::Important,
|
||||||
|
format!("Hello, world at rate {}.", connection.get_voice_rate()),
|
||||||
|
);
|
||||||
connection.set_voice_rate(100);
|
connection.set_voice_rate(100);
|
||||||
connection.say(Priority::Important, "This is faster.");
|
connection.say(Priority::Important, "This is faster.");
|
||||||
connection.set_voice_rate(0);
|
connection.set_voice_rate(0);
|
||||||
|
@ -12,6 +20,9 @@ fn main() {
|
||||||
connection.say(Priority::Important, "This is spelled.");
|
connection.say(Priority::Important, "This is spelled.");
|
||||||
connection.set_spelling(false);
|
connection.set_spelling(false);
|
||||||
connection.set_punctuation(Punctuation::All);
|
connection.set_punctuation(Punctuation::All);
|
||||||
connection.say(Priority::Important, "This statement, unlike others, has punctuation that is spoken!");
|
connection.say(
|
||||||
|
Priority::Important,
|
||||||
|
"This statement, unlike others, has punctuation that is spoken!",
|
||||||
|
);
|
||||||
connection.set_punctuation(Punctuation::None);
|
connection.set_punctuation(Punctuation::None);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,11 +64,7 @@ pub enum CapitalLetters {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn i32_to_bool(v: i32) -> bool {
|
fn i32_to_bool(v: i32) -> bool {
|
||||||
if v == 1 {
|
v == 1
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connection {
|
impl Connection {
|
||||||
|
@ -78,20 +74,21 @@ impl Connection {
|
||||||
user_name: S,
|
user_name: S,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
) -> Connection {
|
) -> Connection {
|
||||||
|
let clientname = CString::new(client_name.into()).unwrap();
|
||||||
|
let connectionname = CString::new(connection_name.into()).unwrap();
|
||||||
|
let username = CString::new(user_name.into()).unwrap();
|
||||||
let connection = unsafe {
|
let connection = unsafe {
|
||||||
spd_open(
|
spd_open(
|
||||||
CString::new(client_name.into()).unwrap().as_ptr(),
|
clientname.as_ptr(),
|
||||||
CString::new(connection_name.into()).unwrap().as_ptr(),
|
connectionname.as_ptr(),
|
||||||
CString::new(user_name.into()).unwrap().as_ptr(),
|
username.as_ptr(),
|
||||||
mode as u32,
|
mode as u32,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
Connection {
|
Connection { connection }
|
||||||
connection: connection,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn open2<S: Into<String>>(
|
pub unsafe fn open2<S: Into<String>>(
|
||||||
client_name: S,
|
client_name: S,
|
||||||
connection_name: S,
|
connection_name: S,
|
||||||
user_name: S,
|
user_name: S,
|
||||||
|
@ -101,17 +98,18 @@ impl Connection {
|
||||||
) -> Connection {
|
) -> Connection {
|
||||||
let auto_spawn = if autospawn { 1 } else { 0 };
|
let auto_spawn = if autospawn { 1 } else { 0 };
|
||||||
let error_result = vec![CString::new("").unwrap().into_raw()].as_mut_ptr();
|
let error_result = vec![CString::new("").unwrap().into_raw()].as_mut_ptr();
|
||||||
let connection = unsafe {
|
let clientname = CString::new(client_name.into()).unwrap();
|
||||||
spd_open2(
|
let connectionname = CString::new(connection_name.into()).unwrap();
|
||||||
CString::new(client_name.into()).unwrap().as_ptr(),
|
let username = CString::new(user_name.into()).unwrap();
|
||||||
CString::new(connection_name.into()).unwrap().as_ptr(),
|
let connection = spd_open2(
|
||||||
CString::new(user_name.into()).unwrap().as_ptr(),
|
clientname.as_ptr(),
|
||||||
mode as u32,
|
connectionname.as_ptr(),
|
||||||
address,
|
username.as_ptr(),
|
||||||
auto_spawn,
|
mode as u32,
|
||||||
error_result,
|
address,
|
||||||
)
|
auto_spawn,
|
||||||
};
|
error_result,
|
||||||
|
);
|
||||||
Connection { connection }
|
Connection { connection }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,24 +118,14 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn say<S: Into<String>>(&self, priority: Priority, text: S) -> bool {
|
pub fn say<S: Into<String>>(&self, priority: Priority, text: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(text.into()).unwrap();
|
||||||
spd_say(
|
let v = unsafe { spd_say(self.connection, priority as u32, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
priority as u32,
|
|
||||||
CString::new(text.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sayf<S: Into<String>>(&self, priority: Priority, format: S) -> bool {
|
pub fn sayf<S: Into<String>>(&self, priority: Priority, format: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(format.into()).unwrap();
|
||||||
spd_sayf(
|
let v = unsafe { spd_sayf(self.connection, priority as u32, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
priority as u32,
|
|
||||||
CString::new(format.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,24 +190,14 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn key<S: Into<String>>(&self, priority: Priority, key_name: S) -> bool {
|
pub fn key<S: Into<String>>(&self, priority: Priority, key_name: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(key_name.into()).unwrap();
|
||||||
spd_key(
|
let v = unsafe { spd_key(self.connection, priority as u32, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
priority as u32,
|
|
||||||
CString::new(key_name.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn char<S: Into<String>>(&self, priority: Priority, char: S) -> bool {
|
pub fn char<S: Into<String>>(&self, priority: Priority, char: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(char.into()).unwrap();
|
||||||
spd_char(
|
let v = unsafe { spd_char(self.connection, priority as u32, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
priority as u32,
|
|
||||||
CString::new(char.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,13 +207,8 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn sound_icon<S: Into<String>>(&self, priority: Priority, icon_name: S) -> bool {
|
pub fn sound_icon<S: Into<String>>(&self, priority: Priority, icon_name: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(icon_name.into()).unwrap();
|
||||||
spd_char(
|
let v = unsafe { spd_char(self.connection, priority as u32, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
priority as u32,
|
|
||||||
CString::new(icon_name.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,33 +243,20 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_synthesis_voice<S: Into<String>>(&self, voice_name: S) -> bool {
|
pub fn set_synthesis_voice<S: Into<String>>(&self, voice_name: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(voice_name.into()).unwrap();
|
||||||
spd_set_synthesis_voice(
|
let v = unsafe { spd_set_synthesis_voice(self.connection, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
CString::new(voice_name.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_synthesis_voice_all<S: Into<String>>(&self, voice_name: S) -> bool {
|
pub fn set_synthesis_voice_all<S: Into<String>>(&self, voice_name: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(voice_name.into()).unwrap();
|
||||||
spd_set_synthesis_voice_all(
|
let v = unsafe { spd_set_synthesis_voice_all(self.connection, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
CString::new(voice_name.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_synthesis_voice_uid<S: Into<String>>(&self, voice_name: S, target_uid: u32) -> bool {
|
pub fn set_synthesis_voice_uid<S: Into<String>>(&self, voice_name: S, target_uid: u32) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(voice_name.into()).unwrap();
|
||||||
spd_set_synthesis_voice_uid(
|
let v = unsafe { spd_set_synthesis_voice_uid(self.connection, param.as_ptr(), target_uid) };
|
||||||
self.connection,
|
|
||||||
CString::new(voice_name.into()).unwrap().as_ptr(),
|
|
||||||
target_uid,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,13 +276,9 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_notification<S: Into<String>>(&self, notification: Notification, state: S) -> bool {
|
pub fn set_notification<S: Into<String>>(&self, notification: Notification, state: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(state.into()).unwrap();
|
||||||
spd_set_notification(
|
let v =
|
||||||
self.connection,
|
unsafe { spd_set_notification(self.connection, notification as u32, param.as_ptr()) };
|
||||||
notification as u32,
|
|
||||||
CString::new(state.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,33 +406,20 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_language<S: Into<String>>(&self, language: S) -> bool {
|
pub fn set_language<S: Into<String>>(&self, language: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(language.into()).unwrap();
|
||||||
spd_set_language(
|
let v = unsafe { spd_set_language(self.connection, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
CString::new(language.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_language_all<S: Into<String>>(&self, language: S) -> bool {
|
pub fn set_language_all<S: Into<String>>(&self, language: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(language.into()).unwrap();
|
||||||
spd_set_language_all(
|
let v = unsafe { spd_set_language_all(self.connection, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
CString::new(language.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_language_uid<S: Into<String>>(&self, language: S, target_uid: u32) -> bool {
|
pub fn set_language_uid<S: Into<String>>(&self, language: S, target_uid: u32) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(language.into()).unwrap();
|
||||||
spd_set_language_uid(
|
let v = unsafe { spd_set_language_uid(self.connection, param.as_ptr(), target_uid) };
|
||||||
self.connection,
|
|
||||||
CString::new(language.into()).unwrap().as_ptr(),
|
|
||||||
target_uid,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -486,22 +429,14 @@ impl Connection {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_output_module<S: Into<String>>(&self, output_module: S) -> bool {
|
pub fn set_output_module<S: Into<String>>(&self, output_module: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(output_module.into()).unwrap();
|
||||||
spd_set_output_module(
|
let v = unsafe { spd_set_output_module(self.connection, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
CString::new(output_module.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_output_module_all<S: Into<String>>(&self, output_module: S) -> bool {
|
pub fn set_output_module_all<S: Into<String>>(&self, output_module: S) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(output_module.into()).unwrap();
|
||||||
spd_set_output_module_all(
|
let v = unsafe { spd_set_output_module_all(self.connection, param.as_ptr()) };
|
||||||
self.connection,
|
|
||||||
CString::new(output_module.into()).unwrap().as_ptr(),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,13 +445,8 @@ impl Connection {
|
||||||
output_module: S,
|
output_module: S,
|
||||||
target_uid: u32,
|
target_uid: u32,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let v = unsafe {
|
let param = CString::new(output_module.into()).unwrap();
|
||||||
spd_set_output_module_uid(
|
let v = unsafe { spd_set_output_module_uid(self.connection, param.as_ptr(), target_uid) };
|
||||||
self.connection,
|
|
||||||
CString::new(output_module.into()).unwrap().as_ptr(),
|
|
||||||
target_uid,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
i32_to_bool(v)
|
i32_to_bool(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user