Skip to content

fix: improve exception handling in tencent tts speech synthesizer#2090

Open
Jah-yee wants to merge 2 commits intoTEN-framework:mainfrom
Jah-yee:fix/tencent-tts-exception-handling
Open

fix: improve exception handling in tencent tts speech synthesizer#2090
Jah-yee wants to merge 2 commits intoTEN-framework:mainfrom
Jah-yee:fix/tencent-tts-exception-handling

Conversation

@Jah-yee
Copy link

@Jah-yee Jah-yee commented Mar 6, 2026

Good day,

Summary

This PR improves exception handling in the Tencent TTS speech synthesizer by:

  1. Replacing bare except with specific exceptions: Changed except: to except (json.JSONDecodeError, ValueError): to catch only the expected JSON parsing errors rather than all possible exceptions.

  2. Using explicit parameter name: Changed r.iter_content(None) to r.iter_content(chunk_size=None) for better code clarity and readability.

Changes

  • File: ai_agents/agents/ten_packages/extension/tencent_tts_python/src/speech_synthesizer.py
    • Line ~99: Replace bare except: with except (json.JSONDecodeError, ValueError):
    • Line ~91: Use explicit chunk_size=None in iter_content()

Testing

  • The code change was verified locally
  • No functional changes, only improvements to code quality and exception handling specificity

感谢你们的奉献,希望能提供帮助。如果我解决得有问题或有待商妥的地方,请在下面留言,我会来处理。

Warmly,

Spark added 2 commits March 6, 2026 08:07
…ension

Replace all print() statements in _send_dingtalk_message method with
ten_env.log_info() and ten_env.log_error() for proper logging.

This ensures logs are handled consistently with the rest of the TEN
framework extension logging pattern instead of going to stdout.
- Replace bare except with specific exceptions (json.JSONDecodeError, ValueError)
- Use explicit chunk_size=None instead of None for clarity in iter_content

These changes improve code quality by:
1. Catching only expected exceptions instead of all exceptions
2. Making the code more readable with explicit parameter name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant