ciyidogan commited on
Commit
4216c57
·
verified ·
1 Parent(s): 0828c34

Update websocket_handler.py

Browse files
Files changed (1) hide show
  1. websocket_handler.py +0 -32
websocket_handler.py CHANGED
@@ -647,38 +647,6 @@ async def generate_and_stream_tts(
647
  audio_size=len(audio_data)
648
  )
649
 
650
- except asyncio.CancelledError:
651
- log_info("TTS streaming cancelled", session_id=session.session.session_id)
652
- raise
653
- except Exception as e:
654
- log_error(
655
- f"TTS generation error",
656
- error=str(e),
657
- session_id=session.session.session_id
658
- )
659
- await websocket.send_json({
660
- "type": "error",
661
- "message": f"TTS error: {str(e)}"
662
- })
663
- await websocket.send_json({
664
- "type": "tts_audio",
665
- "data": base64.b64encode(chunk).decode('utf-8'),
666
- "chunk_index": chunk_index,
667
- "total_chunks": total_chunks,
668
- "is_last": chunk_index == total_chunks - 1,
669
- "mime_type": "audio/mpeg" # ElevenLabs returns MP3
670
- })
671
-
672
- # Small delay to prevent overwhelming the client
673
- await asyncio.sleep(0.01)
674
-
675
- log_info(
676
- f"TTS streaming completed",
677
- session_id=session.session.session_id,
678
- text_length=len(text),
679
- audio_size=len(audio_data)
680
- )
681
-
682
  except asyncio.CancelledError:
683
  log_info("TTS streaming cancelled", session_id=session.session.session_id)
684
  raise
 
647
  audio_size=len(audio_data)
648
  )
649
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
650
  except asyncio.CancelledError:
651
  log_info("TTS streaming cancelled", session_id=session.session.session_id)
652
  raise