diff options
Diffstat (limited to 'crates/asist-app/src/render.rs')
| -rw-r--r-- | crates/asist-app/src/render.rs | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/crates/asist-app/src/render.rs b/crates/asist-app/src/render.rs index 7fd1e86..f62a9bf 100644 --- a/crates/asist-app/src/render.rs +++ b/crates/asist-app/src/render.rs @@ -1,9 +1,9 @@ -//! Presentación en el terminal. +//! Terminal presentation. //! -//! Una sola línea viva que se reescribe con la transcripción provisional, y -//! líneas fijas para lo que ya es definitivo. La distinción importa: ver que -//! el asistente te está oyendo *mientras* hablas es lo que hace que la espera -//! se note menos de lo que dura. +//! One live line rewritten with the partial transcription, and fixed lines +//! for whatever is final. The distinction matters: seeing that the assistant +//! is hearing you *while* you talk is what makes the wait feel shorter than +//! it is. use std::io::Write; use std::time::Duration; @@ -31,8 +31,7 @@ impl Renderer { Self { width: terminal_width(), line_open: false, - // Sin terminal interactivo, los códigos de color sólo ensucian - // el fichero de registro. + // Without an interactive terminal, color codes only pollute the log file. color: std::env::var_os("NO_COLOR").is_none() && is_tty(), show_partials, reply: String::new(), @@ -47,7 +46,7 @@ impl Renderer { } } - /// Borra la línea viva para poder escribir encima algo definitivo. + /// Clears the live line so something final can be written over it. fn close_line(&mut self) { if self.line_open { print!("\r\x1b[K"); @@ -72,7 +71,7 @@ impl Renderer { Event::SpeechStarted { .. } => { self.reply.clear(); if self.show_partials { - self.live(&self.paint(DIM, "escuchando…")); + self.live(&self.paint(DIM, "listening…")); } } Event::Partial { @@ -99,7 +98,7 @@ impl Renderer { self.close_line(); println!( "{} {} {}", - self.paint(BOLD, "tú >"), + self.paint(BOLD, "you >"), text, self.paint( DIM, @@ -112,9 +111,9 @@ impl Renderer { } Event::ReplyStarted { ttft, .. } => { self.close_line(); - print!("{} ", self.paint(CYAN, "asistente >")); + print!("{} ", self.paint(CYAN, "assistant >")); let _ = std::io::stdout().flush(); - tracing::debug!(target: "render", ttft_ms = ttft.as_millis(), "primer token"); + tracing::debug!(target: "render", ttft_ms = ttft.as_millis(), "first token"); } Event::ReplyDelta { text, .. } => { self.reply.push_str(text); @@ -130,7 +129,7 @@ impl Renderer { self.close_line(); println!( "{} {name} {}", - self.paint(YELLOW, "herramienta >"), + self.paint(YELLOW, "tool >"), self.paint(DIM, &short(arguments, 120)) ); } @@ -148,7 +147,7 @@ impl Renderer { }; println!( "{} {name} {mark} {}", - self.paint(YELLOW, "herramienta <"), + self.paint(YELLOW, "tool <"), self.paint( DIM, &format!("{} · {} ms", short(output, 120), took.as_millis()) @@ -157,32 +156,32 @@ impl Renderer { } Event::AudioStarted { latency, .. } => { tracing::info!( - target: "latencia", + target: "latency", ms = latency.as_millis(), - "primer audio (latencia percibida)" + "first audio (perceived latency)" ); if self.color { println!( "{}", - self.paint(DIM, &format!(" ▸ voz en {}", human(*latency))) + self.paint(DIM, &format!(" ▸ voice after {}", human(*latency))) ); } } Event::Sentence { index, text, .. } => { - tracing::debug!(target: "render", frase = index, %text, "a sintetizar"); + tracing::debug!(target: "render", sentence = index, %text, "a sintetizar"); } Event::AudioFinished { .. } => {} Event::Interrupted { reason, .. } => { self.close_line(); let why = match reason { - InterruptReason::UserSpoke => "te has adelantado", - InterruptReason::Requested => "cortado", + InterruptReason::UserSpoke => "you spoke first", + InterruptReason::Requested => "cut", }; println!("{}", self.paint(YELLOW, &format!(" ▪ {why}"))); } Event::Warning { message, .. } => { self.close_line(); - println!("{} {message}", self.paint(YELLOW, "aviso >")); + println!("{} {message}", self.paint(YELLOW, "warning >")); } Event::Failed { message, .. } => { self.close_line(); @@ -240,18 +239,18 @@ mod tests { use super::*; #[test] - fn el_texto_largo_se_recorta_con_puntos_suspensivos() { + fn long_text_is_truncated_with_an_ellipsis() { assert_eq!(short("abcdefghij", 5), "abcde…"); assert_eq!(short("abc", 5), "abc"); } #[test] - fn los_saltos_de_linea_no_rompen_la_linea_viva() { + fn newlines_do_not_break_the_live_line() { assert_eq!(short("a\nb", 10), "a b"); } #[test] - fn las_duraciones_se_leen_en_la_unidad_adecuada() { + fn durations_are_shown_in_the_right_unit() { assert_eq!(human(Duration::from_millis(430)), "430 ms"); assert_eq!(human(Duration::from_millis(2500)), "2.5 s"); } |