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:wait while speaking #238

Merged
merged 2 commits into from
Sep 23, 2024
Merged

fix:wait while speaking #238

merged 2 commits into from
Sep 23, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Sep 23, 2024

didnt realize bools were considered a type of int

isinstance(True, int)
True
isinstance(False, int)
True

Summary by CodeRabbit

  • New Features
    • Improved logic for setting timeout values in audio playback and speaking methods, enhancing responsiveness based on user input.
  • Bug Fixes
    • Resolved issues related to timeout duration assignments, ensuring consistent behavior across different methods.

didnt realize bools were considered a type of int

```
isinstance(True, int)
True
isinstance(False, int)
True
```
Copy link
Contributor

coderabbitai bot commented Sep 23, 2024

Walkthrough

The changes made to the ovos.py file involve a modification to the logic for setting the timeout value within the speak, _play_audio_old, and play_audio methods. The previous implementation assigned the timeout based on the wait parameter's type, while the new logic specifies that if wait is a boolean, timeout defaults to 15 seconds for speak and 30 seconds for the other methods; otherwise, it retains the value of wait. This adjustment clarifies the conditions under which the timeout is determined.

Changes

File Change Summary
ovos_workshop/skills/ovos.py Modified the logic for timeout assignment in the speak, _play_audio_old, and play_audio methods based on the wait parameter.

Poem

In the burrow where rabbits play,
A timeout change brightens the day.
If wait is true, fifteen we say,
For smoother chats, hip-hip-hooray! 🐇✨
With every utterance, joy on display,
Let’s hop to the future, come what may!


Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2042133 and 2ab7ee6.

Files selected for processing (1)
  • ovos_workshop/skills/ovos.py (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ovos_workshop/skills/ovos.py

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 Sep 23, 2024
didnt realize bools were considered a type of int

```
isinstance(True, int)
True
isinstance(False, int)
True
```
@github-actions github-actions bot added fix and removed fix labels Sep 23, 2024
@JarbasAl
Copy link
Member Author

closes #237

Copy link
Contributor

@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 (4)
ovos_workshop/skills/ovos.py (4)

Line range hint 1-31: Review of import statements

While there are no changes in this section, it's worth noting that the imports seem comprehensive and include type hinting support. This is good for code readability and maintainability.

Consider grouping imports by standard library, third-party, and local imports for better organization. For example:

# Standard library imports
import binascii
import datetime
import os
# ... other standard library imports ...

# Third-party imports
from json_database import JsonStorage
from lingua_franca.format import pronounce_number, join_list
# ... other third-party imports ...

# Local imports
from ovos_workshop.decorators.compat import backwards_compat
from ovos_workshop.decorators.killable import AbortEvent, killable_event
# ... other local imports ...

Line range hint 32-1679: Comprehensive OVOSSkill class implementation

The OVOSSkill class provides a robust foundation for skill development. It includes a wide range of methods for handling intents, events, settings, and more. The use of decorators for deprecation and backwards compatibility is commendable.

Consider the following improvements:

  1. Break down this large class into smaller, more focused classes or modules to improve maintainability.
  2. Use more type hints throughout the class to enhance code readability and catch potential type-related errors early.
  3. Consider implementing abstract methods for key skill behaviors, which could be enforced in subclasses.

Example of using abstract methods:

from abc import ABC, abstractmethod

class OVOSSkill(ABC):
    # ... existing code ...

    @abstractmethod
    def initialize(self):
        """
        Initialize the skill. This method must be implemented by all skills.
        """
        pass

    @abstractmethod
    def stop(self):
        """
        Stop the skill's current activity. This method must be implemented by all skills.
        """
        pass

This would ensure that all skills implement these crucial methods.


Line range hint 1684-1685: Proper handling of wait state

This code correctly handles the case when wait is True, ensuring that the method waits for the speech to complete before proceeding. The use of SessionManager is appropriate for managing the session state.

For improved readability, consider adding a brief comment explaining the purpose of this block:

if wait:
    # Wait for speech to complete if wait is True
    timeout = 15 if isinstance(wait, bool) else wait
    sess = SessionManager.get(m)
    sess.is_speaking = True
    SessionManager.wait_while_speaking(timeout, sess)

Line range hint 1-1685: Overall assessment of OVOSSkill class

The changes made to the speak method effectively address the PR objective of handling boolean values correctly. The OVOSSkill class provides a comprehensive foundation for skill development with a wide range of functionalities.

While the current implementation is functional, consider the following architectural improvements for future iterations:

  1. Modularization: Break down the large OVOSSkill class into smaller, more focused classes or modules. This could improve maintainability and make it easier for developers to understand and extend specific functionalities.

  2. Consistent use of type hints: Implement type hints throughout the class to improve code readability and catch potential type-related errors early in development.

  3. Abstract base class: Consider turning OVOSSkill into an abstract base class with some abstract methods that all skills must implement. This could enforce a more consistent structure across different skills.

  4. Documentation: While there are docstrings present, consider adding more detailed documentation for complex methods, especially those intended for use by skill developers.

These suggestions aim to improve the overall architecture and maintainability of the codebase while preserving its current functionality.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e4b1677 and 2042133.

Files selected for processing (1)
  • ovos_workshop/skills/ovos.py (1 hunks)
Additional comments not posted (1)
ovos_workshop/skills/ovos.py (1)

1680-1683: Improved handling of wait parameter

This change correctly addresses the issue with boolean values being treated as integers in Python. Now, if wait is a boolean, the timeout is set to 15 seconds, otherwise it uses the value of wait. This prevents potential bugs when True (which equals 1 in Python) is passed as the wait parameter.

Copy link

codecov bot commented Sep 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 49.17%. Comparing base (7c02206) to head (2ab7ee6).
Report is 17 commits behind head on dev.

Files with missing lines Patch % Lines
ovos_workshop/skills/ovos.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #238      +/-   ##
==========================================
- Coverage   53.41%   49.17%   -4.25%     
==========================================
  Files          37       37              
  Lines        4362     4362              
==========================================
- Hits         2330     2145     -185     
- Misses       2032     2217     +185     
Flag Coverage Δ
48.47% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 Sep 23, 2024
@JarbasAl JarbasAl merged commit ae5ef64 into dev Sep 23, 2024
9 of 10 checks passed
@JarbasAl JarbasAl deleted the fix/wait_while_speaking branch September 23, 2024 16:51
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.

1 participant