mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
retrofit more tts in various corner cases
This commit is contained in:
parent
dc2c393c5c
commit
ac059eae48
7 changed files with 61 additions and 5 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1970,6 +1970,7 @@ dependencies = [
|
|||
"susres",
|
||||
"ticktimer-server",
|
||||
"trng",
|
||||
"tts-frontend",
|
||||
"utralib",
|
||||
"xous",
|
||||
"xous-ipc 0.9.7",
|
||||
|
|
|
|||
|
|
@ -279,10 +279,6 @@ impl<'a> Menu<'a> {
|
|||
}
|
||||
log::trace!("menu redraw##");
|
||||
self.gam.redraw().unwrap();
|
||||
#[cfg(feature="tts")]
|
||||
{
|
||||
self.tts.tts_simple(&self.name).unwrap();
|
||||
}
|
||||
}
|
||||
fn num_items(&self) -> usize {
|
||||
self.items.len()
|
||||
|
|
@ -299,6 +295,12 @@ impl<'a> Menu<'a> {
|
|||
}
|
||||
if let Some(action) = mi.action_conn {
|
||||
log::debug!("doing menu action for {}", mi.name);
|
||||
#[cfg(feature="tts")]
|
||||
{
|
||||
let mut phrase = "select ".to_string();
|
||||
phrase.push_str(mi.name.as_str().unwrap());
|
||||
self.tts.tts_blocking(&phrase).unwrap();
|
||||
}
|
||||
match mi.action_payload {
|
||||
MenuPayload::Scalar(args) => {
|
||||
xous::send_message(action,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,9 @@ graphics-server = {path = "../graphics-server"}
|
|||
# for reboots and fuse operations
|
||||
jtag = {path = "../jtag"}
|
||||
|
||||
# for text to speech support
|
||||
tts-frontend = {path="../tts"}
|
||||
|
||||
# private keys
|
||||
#sha2 = {version = "0.9.5", default-features = false, features = []}
|
||||
sha2 = {path = "../engine-sha512"}
|
||||
|
|
@ -67,6 +70,7 @@ utralib = { path = "../../utralib"}
|
|||
[features]
|
||||
policy-menu = [] # provisions for users to set their password retention policies (on the block for deprecation) (note: to re-enable you need to add "rootkeys menu" to the tokens.rs in the GAM)
|
||||
hazardous-debug = [] # this feature enables the printing of secret materials for debug purposes
|
||||
tts = []
|
||||
default = []
|
||||
|
||||
[lib]
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ use gam::modal::*;
|
|||
#[cfg(feature = "policy-menu")]
|
||||
use gam::{MenuItem, MenuPayload};
|
||||
|
||||
#[cfg(feature = "tts")]
|
||||
use tts_frontend::*;
|
||||
|
||||
use locales::t;
|
||||
use std::format;
|
||||
use std::str;
|
||||
|
|
@ -327,6 +330,9 @@ fn xmain() -> ! {
|
|||
let main_cid = xous::connect(keys_sid).expect("couldn't create suspend callback connection");
|
||||
let mut susres = susres::Susres::new(None, &xns, api::Opcode::SuspendResume as u32, main_cid).expect("couldn't create suspend/resume object");
|
||||
|
||||
#[cfg(feature="tts")]
|
||||
let tts = TtsFrontend::new(&xns).unwrap();
|
||||
|
||||
// create a policy menu object
|
||||
#[cfg(feature = "policy-menu")]
|
||||
{
|
||||
|
|
@ -459,6 +465,8 @@ fn xmain() -> ! {
|
|||
|
||||
if keys.is_initialized() {
|
||||
modals.show_notification(t!("rootkeys.already_init", xous::LANG)).expect("modals error");
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.already_init", xous::LANG)).unwrap();
|
||||
keys.set_ux_password_type(None);
|
||||
continue;
|
||||
} else {
|
||||
|
|
@ -489,6 +497,8 @@ fn xmain() -> ! {
|
|||
Some(t!("rootkeys.bootpass", xous::LANG)), false,
|
||||
None, true, None
|
||||
);
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.bootpass", xous::LANG)).unwrap();
|
||||
rootkeys_modal.activate();
|
||||
}
|
||||
}),
|
||||
|
|
@ -511,6 +521,8 @@ fn xmain() -> ! {
|
|||
Some(t!("rootkeys.updatepass", xous::LANG)), false,
|
||||
None, true, None
|
||||
);
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.updatepass", xous::LANG)).unwrap();
|
||||
rootkeys_modal.activate();
|
||||
},
|
||||
Some(Opcode::UxInitUpdatePasswordReturn) => {
|
||||
|
|
@ -705,6 +717,8 @@ fn xmain() -> ! {
|
|||
Some(t!("rootkeys.get_update_password", xous::LANG)), false,
|
||||
None, true, None
|
||||
);
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.get_update_password", xous::LANG)).unwrap();
|
||||
rootkeys_modal.activate();
|
||||
}
|
||||
}
|
||||
|
|
@ -780,6 +794,8 @@ fn xmain() -> ! {
|
|||
Some(t!("rootkeys.get_signing_password", xous::LANG)), false,
|
||||
None, true, None
|
||||
);
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.get_signing_password", xous::LANG)).unwrap();
|
||||
rootkeys_modal.activate();
|
||||
}
|
||||
},
|
||||
|
|
@ -858,6 +874,8 @@ fn xmain() -> ! {
|
|||
Some(t!("rootkeys.get_login_password", xous::LANG)), false,
|
||||
None, true, None
|
||||
);
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.get_login_password", xous::LANG)).unwrap();
|
||||
rootkeys_modal.activate();
|
||||
// note that the scalar is *not* yet returned, it will be returned by the opcode called by the password assurance
|
||||
} else {
|
||||
|
|
@ -893,6 +911,8 @@ fn xmain() -> ! {
|
|||
Some(ActionType::RadioButtons(confirm_radiobox)),
|
||||
Some(t!("rootkeys.policy_request", xous::LANG)), false,
|
||||
None, true, None);
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.policy_request", xous::LANG)).unwrap();
|
||||
rootkeys_modal.activate();
|
||||
},
|
||||
Some(Opcode::UxAesEnsureReturn) => {
|
||||
|
|
@ -968,6 +988,8 @@ fn xmain() -> ! {
|
|||
Some(ActionType::ConsoleInput(console_input)),
|
||||
Some(t!("rootkeys.console_input", xous::LANG)), false,
|
||||
None, true, None);
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.console_input", xous::LANG)).unwrap();
|
||||
rootkeys_modal.activate();
|
||||
log::info!("{}check_conn", CONSOLE_SENTINEL);
|
||||
}
|
||||
|
|
@ -990,6 +1012,8 @@ fn xmain() -> ! {
|
|||
Some(t!("rootkeys.get_signing_password", xous::LANG)), false,
|
||||
None, true, None
|
||||
);
|
||||
#[cfg(feature="tts")]
|
||||
tts.tts_blocking(t!("rootkeys.get_signing_password", xous::LANG)).unwrap();
|
||||
rootkeys_modal.activate();
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,10 @@ pub(crate) const SERVER_NAME_TTS: &str = "_Text to speech front end_";
|
|||
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
pub(crate) enum Opcode {
|
||||
/// Basic, synchronous, non-abortable conversion of a string to audible speech
|
||||
/// Basic, interruptable conversion of a string to audible speech
|
||||
TextToSpeech,
|
||||
/// Non-interruptable conversion of a string to audible speech. Blocks until the phrase is finished.
|
||||
TextToSpeechBlocking,
|
||||
/// Callback for the codec crate
|
||||
CodecCb,
|
||||
/// Stops audio playback immediately. Does not stop wave generation.
|
||||
|
|
|
|||
|
|
@ -27,6 +27,14 @@ impl TtsFrontend {
|
|||
let buf = Buffer::into_buf(msg).or(Err(xous::Error::InternalError))?;
|
||||
buf.lend(self.conn, Opcode::TextToSpeech.to_u32().unwrap()).map(|_| ())
|
||||
}
|
||||
/// This blocks until the text is finished rendering
|
||||
pub fn tts_blocking(&self, text: &str) -> Result<(), xous::Error> {
|
||||
let msg = TtsFrontendMsg {
|
||||
text: xous_ipc::String::from_str(text),
|
||||
};
|
||||
let buf = Buffer::into_buf(msg).or(Err(xous::Error::InternalError))?;
|
||||
buf.lend(self.conn, Opcode::TextToSpeechBlocking.to_u32().unwrap()).map(|_| ())
|
||||
}
|
||||
pub fn set_words_per_minute(&self, wpm: u32) -> Result<(), xous::Error> {
|
||||
send_message(self.conn,
|
||||
Message::new_scalar(Opcode::SetWordsPerMinute.to_usize().unwrap(), wpm as usize, 0, 0, 0)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use std::sync::atomic::{AtomicBool, Ordering};
|
|||
use std::collections::VecDeque;
|
||||
|
||||
const DEFAULT_WPM: u32 = 350;
|
||||
const WAIT_INTERVAL: usize = 50; // milliseconds to wait before polling if a phrase is finished.
|
||||
|
||||
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||
pub(crate) enum WaveOp {
|
||||
|
|
@ -114,6 +115,20 @@ fn xmain() -> ! {
|
|||
log::debug!("resuming codec");
|
||||
codec.resume().unwrap();
|
||||
},
|
||||
Some(Opcode::TextToSpeechBlocking) => {
|
||||
let buffer = unsafe { Buffer::from_memory_message(msg.body.memory_message().unwrap()) };
|
||||
let msg = buffer.to_original::<TtsFrontendMsg, _>().unwrap();
|
||||
log::debug!("tts blocking front end got string {}", msg.text.as_str().unwrap());
|
||||
wavbuf.lock().unwrap().clear(); // this will truncate any buffered audio that is playing
|
||||
synth_done.store(false, Ordering::SeqCst);
|
||||
tts_be.tts_simple(msg.text.as_str().unwrap()).unwrap();
|
||||
just_initiated = true;
|
||||
log::debug!("resuming codec (blocking)");
|
||||
codec.resume().unwrap();
|
||||
while !synth_done.load(Ordering::SeqCst) {
|
||||
tt.sleep_ms(WAIT_INTERVAL).unwrap();
|
||||
}
|
||||
},
|
||||
Some(Opcode::CodecCb) => msg_scalar_unpack!(msg, free_play, _available_rec, _, routing_id, {
|
||||
if routing_id == codec::AUDIO_CB_ROUTING_ID {
|
||||
let mut frames: FrameRing = FrameRing::new();
|
||||
|
|
|
|||
Loading…
Reference in a new issue