-
-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix:b64 improvements #107
fix:b64 improvements #107
Conversation
WalkthroughThe changes in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (2)
ovos_audio/service.py (2)
57-59
: LGTM! Constructor changes improve flexibility and type safety.The addition of
tts
anddisable_fallback
parameters enhances configurability and testability. Type hints improve code clarity.Consider adding docstring parameters for the new arguments:
def __init__(self, ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping, alive_hook=on_alive, started_hook=on_started, watchdog=lambda: None, bus=None, disable_ocp=None, validate_source=True, tts: Optional[TTS] = None, disable_fallback: bool = False): + """ + Args: + tts: Optional TTS instance for dependency injection + disable_fallback: If True, disables fallback TTS loading + """Also applies to: 74-79
282-294
: Consider adding error handling for file operations.While the changes improve the API and file handling, consider adding error handling for file operations to gracefully handle potential I/O errors.
-with open(str(wav), "rb") as f: - audio = f.read() - -b64_audio = base64.b64encode(audio).decode("utf-8") -self.bus.emit(message.response({"audio": b64_audio, - "listen": listen, - 'tts_id': self.tts.plugin_id, - "utterance": utterance})) +try: + with open(str(wav), "rb") as f: + audio = f.read() + b64_audio = base64.b64encode(audio).decode("utf-8") + self.bus.emit(message.response({"audio": b64_audio, + "listen": listen, + 'tts_id': self.tts.plugin_id, + "utterance": utterance})) +except IOError as e: + LOG.error(f"Failed to read audio file: {e}") + self.bus.emit(message.response({"error": str(e)}))
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- ovos_audio/service.py (11 hunks)
🧰 Additional context used
🔇 Additional comments (3)
ovos_audio/service.py (3)
Line range hint
350-376
: LGTM! Improved TTS reload logic with better control flow.The addition of early returns for disabled reload and fallback scenarios improves code readability and provides better control over TTS behavior.
471-471
: LGTM! Type annotations improve code clarity.The addition of return type hints to
_resolve_sound_uri
,_path_from_hexdata
, and_get_tts_fallback
methods improves code clarity and maintainability.Also applies to: 485-485, 414-414
451-453
: Previous review comment about protected member access is still applicable.The concern about accessing the protected member
_now_playing
ofplayback
object remains valid.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation