Skip to content
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:improve stop #260

Merged
merged 1 commit into from
Oct 21, 2024
Merged

fix:improve stop #260

merged 1 commit into from
Oct 21, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 21, 2024

also stop ongoing TTS

partial fix, TODO in code for later

related OpenVoiceOS/ovos-skill-wikihow#18

Summary by CodeRabbit

  • New Features

    • Enhanced audio playback management with improved stop handling.
    • Added checks to ensure audio stops correctly when using the default session.
  • Bug Fixes

    • Improved error handling for stop requests, ensuring clearer logging of exceptions.
  • Refactor

    • Updated method signatures for better clarity and type safety.

also stop ongoing TTS

partial fix, TODO in code for later
Copy link

coderabbitai bot commented Oct 21, 2024

Walkthrough

The changes in the ovos_workshop/skills/ovos.py file focus on enhancing the OVOSSkill class, specifically its stop and shutdown methods. Modifications include additional checks in the stop method for audio playback based on the session ID, updates to the __handle_stop method to ensure it consistently returns a boolean value, and improvements in error handling for clearer logging of exceptions during the stop process.

Changes

File Path Change Summary
ovos_workshop/skills/ovos.py - Enhanced stop method to emit a stop audio message for "default" session ID.
- Updated __handle_stop method to return False if no truthy result from stop_session or stop.
- Improved error handling in __handle_stop for clearer exception logging.
- Updated method signatures for stop and __handle_stop to include return types.

Poem

In the workshop where skills do play,
A stop and a shutdown brighten the day.
With messages clear, and errors in sight,
Our rabbit friends hop with pure delight! 🐇✨
So let the audio pause, and the skills all shine,
For every little change makes our work divine!


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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the fix label Oct 21, 2024
Copy link

codecov bot commented Oct 21, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 51.48%. Comparing base (7c02206) to head (46e8bb2).
Report is 59 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_workshop/skills/ovos.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #260      +/-   ##
==========================================
- Coverage   53.41%   51.48%   -1.93%     
==========================================
  Files          37       36       -1     
  Lines        4362     4195     -167     
==========================================
- Hits         2330     2160     -170     
- Misses       2032     2035       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added fix and removed fix labels Oct 21, 2024
Copy link

@coderabbitai coderabbitai bot left a 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 (3)
ovos_workshop/skills/ovos.py (3)

1240-1245: Approved with suggestions for improvement

The addition of the audio stop message for the default session is a good improvement. However, consider the following suggestions:

  1. Add a more detailed comment explaining why we only stop audio for the "default" session.
  2. The TODO comment about tracking speech origin should be addressed in future updates.

Consider adding a more detailed comment like this:

# Stop audio playback only for the default session
# This ensures we don't interfere with other active sessions
if data["result"] and sess.session_id == "default":
    # TODO: Implement proper tracking of speech origin per skill
    self.bus.emit(message.reply("mycroft.audio.speech.stop",
                                {"skill_id": self.skill_id}))

1256-1256: Approved with a suggestion for readability

The modification to include both stop_session and stop methods in the stop handling logic is a good improvement. It ensures that both session-specific and general stop actions are performed.

Consider refactoring the line for better readability:

stopped = self.stop_session(sess) or self.stop() or False

This change maintains the same logic but makes it easier to understand at a glance.


1240-1245: Approved with suggestion for improved deprecation warning

The addition of the network_requirements property for backwards compatibility is a good practice. However, to ensure developers are well-informed about the deprecation, consider using the warnings module.

Consider modifying the implementation to use the warnings module:

import warnings

@classproperty
def network_requirements(self) -> RuntimeRequirements:
    warnings.warn("network_requirements is deprecated and will be removed in ovos-core 0.0.8. "
                  "Use runtime_requirements instead.", DeprecationWarning, stacklevel=2)
    return self.runtime_requirements

This change will provide a more visible deprecation warning to developers using this property.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 9ab925c and 46e8bb2.

📒 Files selected for processing (1)
  • ovos_workshop/skills/ovos.py (2 hunks)
🧰 Additional context used

@JarbasAl JarbasAl merged commit abd409e into dev Oct 21, 2024
10 of 11 checks passed
@JarbasAl JarbasAl deleted the fix/better_stop branch October 21, 2024 23:12
@goldyfruit
Copy link
Member

Works for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants