mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-08 04:56:43 +00:00
add tts locale to hello example
This commit is contained in:
parent
731b847560
commit
b4d20a643c
4 changed files with 26 additions and 1 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1035,10 +1035,12 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"gam",
|
||||
"graphics-server",
|
||||
"locales",
|
||||
"log",
|
||||
"log-server",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"tts-frontend",
|
||||
"xous",
|
||||
"xous-ipc 0.9.7",
|
||||
"xous-names",
|
||||
|
|
|
|||
|
|
@ -13,3 +13,9 @@ log-server = { path = "../../services/log-server" }
|
|||
xous-names = { path = "../../services/xous-names" }
|
||||
gam = {path = "../../services/gam" }
|
||||
graphics-server = {path = "../../services/graphics-server" }
|
||||
locales = {path = "../../locales"}
|
||||
tts-frontend = {path="../../services/tts"}
|
||||
|
||||
[features]
|
||||
tts = []
|
||||
default = []
|
||||
|
|
|
|||
8
apps/hello/locales/i18n.json
Normal file
8
apps/hello/locales/i18n.json
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"helloworld.hello": {
|
||||
"en": "Hello World!",
|
||||
"ja": "Hello World!",
|
||||
"zh": "大家好!",
|
||||
"en-tts": "Hello World!"
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,9 @@ use core::fmt::Write;
|
|||
use graphics_server::api::GlyphStyle;
|
||||
use graphics_server::{DrawStyle, Gid, PixelColor, Point, Rectangle, TextBounds, TextView};
|
||||
use num_traits::*;
|
||||
use locales::t;
|
||||
#[cfg(feature = "tts")]
|
||||
use tts_frontend::*;
|
||||
|
||||
/// Basic 'Hello World!' application that draws a simple
|
||||
/// TextView to the screen.
|
||||
|
|
@ -26,6 +29,8 @@ struct Hello {
|
|||
gam: gam::Gam,
|
||||
_gam_token: [u32; 4],
|
||||
screensize: Point,
|
||||
#[cfg(feature = "tts")]
|
||||
tts: TtsFrontend,
|
||||
}
|
||||
|
||||
impl Hello {
|
||||
|
|
@ -57,6 +62,8 @@ impl Hello {
|
|||
_gam_token: gam_token,
|
||||
content,
|
||||
screensize,
|
||||
#[cfg(feature = "tts")]
|
||||
tts: TtsFrontend::new(xns).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,7 +105,9 @@ impl Hello {
|
|||
text_view.clear_area = true;
|
||||
text_view.rounded_border = Some(3);
|
||||
text_view.style = GlyphStyle::Regular;
|
||||
write!(text_view.text, "{}", "Hello world!").expect("Could not write to text view");
|
||||
write!(text_view.text, "{}", t!("helloworld.hello", xous::LANG)).expect("Could not write to text view");
|
||||
#[cfg(feature="tts")]
|
||||
self.tts.tts_simple(t!("helloworld.hello", xous::LANG)).unwrap();
|
||||
|
||||
self.gam
|
||||
.post_textview(&mut text_view)
|
||||
|
|
|
|||
Loading…
Reference in a new issue