diff --git a/speech-dispatcher/src/lib.rs b/speech-dispatcher/src/lib.rs index db18dbb..ce889c6 100644 --- a/speech-dispatcher/src/lib.rs +++ b/speech-dispatcher/src/lib.rs @@ -118,13 +118,21 @@ impl Connection { } pub fn say>(&self, priority: Priority, text: S) -> bool { - let param = CString::new(text.into()).unwrap(); + let text: String = text.into(); + if text.is_empty() { + return true; + } + let param = CString::new(text).unwrap(); let v = unsafe { spd_say(self.connection, priority as u32, param.as_ptr()) }; i32_to_bool(v) } pub fn sayf>(&self, priority: Priority, format: S) -> bool { - let param = CString::new(format.into()).unwrap(); + let format: String = format.into(); + if format.is_empty() { + return true; + } + let param = CString::new(format).unwrap(); let v = unsafe { spd_sayf(self.connection, priority as u32, param.as_ptr()) }; i32_to_bool(v) }