File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,13 @@ impl ParaformerRealtimeV2Asr {
125125 log:: debug!( "Received message: {:?}" , text) ;
126126
127127 let response: ResponseMessage = serde_json:: from_str ( & text) ?;
128+ if response. header . task_id != self . task_id {
129+ log:: warn!(
130+ "Received message for different task_id: {}" ,
131+ response. header. task_id
132+ ) ;
133+ continue ;
134+ }
128135
129136 if response. is_task_started ( ) {
130137 log:: info!( "Recognition task started" ) ;
Original file line number Diff line number Diff line change @@ -43,9 +43,19 @@ impl ParaformerASRSession {
4343 }
4444 ClientMsg :: StartChat => {
4545 log:: info!( "`{id}` starting paraformer asr" ) ;
46- self . start_pcm_recognition ( ) . await . map_err ( |e| {
47- anyhow:: anyhow!( "`{id}` error starting paraformer asr: {e}" )
48- } ) ?;
46+ if let Err ( e) = self . start_pcm_recognition ( ) . await {
47+ log:: warn!(
48+ "`{id}` error starting paraformer asr: {e}, attempting to reconnect..."
49+ ) ;
50+ self . reconnect ( ) . await . map_err ( |e| {
51+ anyhow:: anyhow!( "`{id}` error reconnecting paraformer asr: {e}" )
52+ } ) ?;
53+ log:: info!( "`{id}` paraformer asr reconnected successfully" ) ;
54+ self . start_pcm_recognition ( ) . await . map_err ( |e| {
55+ anyhow:: anyhow!( "`{id}` error starting paraformer asr: {e}" )
56+ } ) ?;
57+ }
58+
4959 continue ;
5060 }
5161 }
You can’t perform that action at this time.
0 commit comments