File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ impl ParaformerRealtimeV2Asr {
157157
158158 pub async fn next_result ( & mut self ) -> anyhow:: Result < Option < ResponsePayloadOutputSentence > > {
159159 while let Some ( message) = self . websocket . next ( ) . await {
160- match message? {
160+ match message. map_err ( |e| anyhow :: anyhow! ( "Paraformer ASR WebSocket error: {}" , e ) ) ? {
161161 reqwest_websocket:: Message :: Binary ( _) => {
162162 log:: debug!( "Received unexpected binary message" ) ;
163163 }
Original file line number Diff line number Diff line change @@ -457,7 +457,9 @@ async fn get_paraformer_v2_text(
457457 ClientMsg :: AudioChunk ( data) => {
458458 samples. extend_from_slice ( & data) ;
459459 if let Some ( asr) = asr. as_mut ( ) {
460- asr. send_audio ( data) . await ?;
460+ asr. send_audio ( data) . await . map_err ( |e| {
461+ anyhow:: anyhow!( "`{id}` error sending paraformer asr audio: {e}" )
462+ } ) ?;
461463 }
462464 }
463465 ClientMsg :: Submit => {
@@ -474,7 +476,9 @@ async fn get_paraformer_v2_text(
474476 )
475477 . await ?;
476478
477- paraformer_asr. start_pcm_recognition ( ) . await ?;
479+ paraformer_asr. start_pcm_recognition ( ) . await . map_err ( |e| {
480+ anyhow:: anyhow!( "`{id}` error starting paraformer asr: {e}" )
481+ } ) ?;
478482 asr = Some ( paraformer_asr) ;
479483 continue ;
480484 }
@@ -498,9 +502,15 @@ async fn get_paraformer_v2_text(
498502 log:: error!( "`{id}` error writing asr file {id}: {e}" ) ;
499503 } ;
500504 samples. clear ( ) ;
501- asr. finish_task ( ) . await ?;
505+ asr. finish_task ( )
506+ . await
507+ . map_err ( |e| anyhow:: anyhow!( "`{id}` error finishing paraformer asr task: {e}" ) ) ?;
502508 let mut text = String :: new ( ) ;
503- while let Some ( sentence) = asr. next_result ( ) . await ? {
509+ while let Some ( sentence) = asr
510+ . next_result ( )
511+ . await
512+ . map_err ( |e| anyhow:: anyhow!( "`{id}` error getting paraformer asr result: {e}" ) ) ?
513+ {
504514 if sentence. sentence_end {
505515 text = sentence. text ;
506516 log:: info!( "ASR final result: {:?}" , text) ;
You can’t perform that action at this time.
0 commit comments