ui: add some sfx integration to the UI, fix a json crash
This commit is contained in:
@@ -6,7 +6,7 @@ use tokio::time::Instant;
|
||||
use tui_input::{Input, backend::crossterm::EventHandler};
|
||||
use tui_skeleton::{AnimationMode, Block, Constraint, SkeletonText};
|
||||
|
||||
use crate::{audio::AudioInputControl, prediction::{GeneratedResponses, PredictionAction, SessionControl, SessionUpdate}, scene::{Scene, conversation::{ConversationEntry, Speaker}}, transcription::TranscriptionControl, tts::TtsControl};
|
||||
use crate::{audio::AudioInputControl, prediction::{GeneratedResponses, PredictionAction, SessionControl, SessionUpdate}, scene::{Scene, conversation::{ConversationEntry, Speaker}}, sfx::SfxControl, transcription::TranscriptionControl, tts::TtsControl};
|
||||
use crate::widgets::*;
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -30,7 +30,8 @@ pub struct Ui {
|
||||
audio: AudioInputControl,
|
||||
tts: TtsControl,
|
||||
predictions: SessionControl,
|
||||
conversation: Vec<ConversationEntry>
|
||||
conversation: Vec<ConversationEntry>,
|
||||
sfx: SfxControl
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -40,7 +41,7 @@ enum FocusState {
|
||||
}
|
||||
|
||||
impl Ui {
|
||||
pub fn new(predictions: SessionControl, audio: AudioInputControl, transcription: TranscriptionControl, tts: TtsControl) -> Self {
|
||||
pub fn new(predictions: SessionControl, audio: AudioInputControl, transcription: TranscriptionControl, tts: TtsControl, sfx: SfxControl) -> Self {
|
||||
Self {
|
||||
scene: Default::default(),
|
||||
reply_state: Default::default(),
|
||||
@@ -58,7 +59,8 @@ impl Ui {
|
||||
predictions,
|
||||
last_tick: Instant::now(),
|
||||
conversation: vec![],
|
||||
reply_options: Default::default()
|
||||
reply_options: Default::default(),
|
||||
sfx
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +195,9 @@ impl Ui {
|
||||
"/computer" => {
|
||||
self.predictions.insert(PredictionAction::ComputerCommand(arg.to_string())).await;
|
||||
},
|
||||
"/ambient" => {
|
||||
self.sfx.play_ambient().await.unwrap()
|
||||
},
|
||||
_ => {
|
||||
log::error!("Unknown command. Available commands: /episode [number], /narrative [text], /event [text], /computer [text], /timer [minutes]");
|
||||
}
|
||||
@@ -220,6 +225,7 @@ impl Ui {
|
||||
let row_num = self.conversation_state.selected().unwrap();
|
||||
if let ConversationEntry::Spoken(Speaker::Eva, text) = &self.conversation[self.conversation.len() - 1 - row_num] {
|
||||
self.tts.speak(text.clone()).await.unwrap();
|
||||
self.sfx.play_ambient().await.unwrap();
|
||||
self.focus_state = FocusState::UserInput;
|
||||
self.conversation_state.select(None);
|
||||
self.reply_state.select_first();
|
||||
|
||||
Reference in New Issue
Block a user