Skip to content

Commit f9d904a

Browse files
committed
fix: device cannot recover to listening when the llm and tts fail
1 parent cf3f8b5 commit f9d904a

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

src/services/ws/stable/mod.rs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,21 @@ async fn run_session(
152152
let llm_fut = llm::chat(tts_req_tx, chunks_tx, chat_session, text);
153153
let send_audio_fut = handle_tts_requests(chunks_rx, session);
154154

155-
let _ = tokio::try_join!(llm_fut, send_audio_fut)?;
156-
157-
log::info!(
158-
"{}:{:x} session processing done for this input",
159-
session.id,
160-
session.request_id
161-
);
155+
let r = tokio::try_join!(llm_fut, send_audio_fut);
156+
if let Err(e) = r {
157+
log::error!(
158+
"{}:{:x} error during llm or tts handling: {}",
159+
session.id,
160+
session.request_id,
161+
e
162+
);
163+
} else {
164+
log::info!(
165+
"{}:{:x} session processing done for this input",
166+
session.id,
167+
session.request_id
168+
);
169+
}
162170

163171
session
164172
.cmd_tx

src/services/ws/stable/tts.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,22 @@ impl TTSSessionPool {
176176
}
177177

178178
pub async fn run_loop(&mut self, mut rx: TTSRequestRx) -> anyhow::Result<()> {
179+
let mut sucess_workers = 0;
179180
for i in 0..self.workers {
180-
let session = self.create_session().await?;
181-
tokio::spawn(Self::run_session(i as u128, session, self.tx.clone()));
181+
match self.create_session().await {
182+
Ok(session) => {
183+
tokio::spawn(Self::run_session(i as u128, session, self.tx.clone()));
184+
sucess_workers += 1;
185+
}
186+
Err(e) => {
187+
log::error!("create tts session[{i}] error: {}", e);
188+
continue;
189+
}
190+
};
191+
}
192+
193+
if sucess_workers == 0 {
194+
return Err(anyhow::anyhow!("no available tts session worker"));
182195
}
183196

184197
while let Some(tts_req) = rx.recv().await {

0 commit comments

Comments
 (0)