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/ducking #78

Merged
merged 1 commit into from
Jul 17, 2024
Merged

fix/ducking #78

merged 1 commit into from
Jul 17, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Jul 16, 2024

ensure volume is restored when ovos-core signals an utterance has been fully handled

in some cases volume could stay lowered and never be restored, this can be reproduced with "stop" commands under some circumstances

closes #77

Summary by CodeRabbit

  • New Features

    • Improved volume control for speaking and recording events.
    • Added a new attribute to track speaking status.
  • Improvements

    • Updated logging messages for better clarity and debugging.
  • Bug Fixes

    • Enhanced event handling for audio ducking and volume control.
  • Maintenance

    • Refined logic for selecting the appropriate audio player service based on URI type.

ensure volume is restored when ovos-core signals an utterance has been fully handled

in some cases volume could stay lowered and never be restored, this can be reproduced with "stop" commands under some circumstances

closes #77
@JarbasAl JarbasAl added the bug Something isn't working label Jul 16, 2024
@JarbasAl JarbasAl requested review from a team July 16, 2024 21:12
Copy link
Contributor

coderabbitai bot commented Jul 16, 2024

Walkthrough

The recent changes to ovos_audio/audio.py aim to improve audio volume control and event handling. These modifications include the introduction of new attributes and methods for managing volume during speaking and recording events, enhanced logging, and refactored event handlers. Additionally, the logic for selecting audio player services based on URI type has been adjusted to ensure proper volume persistence, resolving issues related to volume ducking when restarting the OCP skill.

Changes

Files Change Summary
ovos_audio/audio.py Added volume_is_speaking attribute, renamed and added methods for volume control, updated event handlers, improved logging, modified audio player service selection logic, added utterance completion handler, updated shutdown method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AudioService
    participant EventHandler
    participant AudioPlayer
    User->>AudioService: Start OCP Skill
    AudioService->>EventHandler: Subscribe to events
    User->>AudioService: Play radio station
    AudioService->>AudioPlayer: Initialize with volume 65
    User->>AudioService: Stop OCP Skill
    AudioService->>AudioPlayer: Duck volume to 30
    AudioService->>EventHandler: Unsubscribe from events
    User->>AudioService: Restart radio station
    AudioService->>AudioPlayer: Restore volume to 65
Loading

Assessment against linked issues

Objective Addressed Explanation
Identify and Fix Volume Ducking Bug (#77)
Investigate Volume Persistence (#77)
Review and Analyze Logs (#77)

Poem

In the realm of code so bright,
Where volumes duck and rise in light,
Audio whispers, loud then low,
A dance of sound in perfect flow.
With changes made and bugs now gone,
OCP sings its flawless song.
🎵🐇


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f5fccb0 and 4e7b0d0.

Files selected for processing (1)
  • ovos_audio/audio.py (6 hunks)
Additional comments not posted (7)
ovos_audio/audio.py (7)

81-81: Added attribute for speaking volume state.

The new attribute volume_is_speaking is introduced to track when the system is speaking. This is a good practice as it helps in managing the state of the system more effectively.


177-179: New event handlers for audio service and ducking events.

The addition of new event handlers for track position and audio ducking events enhances the control over audio playback and interaction during voice recognition and speech output. This aligns well with the PR's objective to handle audio ducking issues effectively.

Also applies to: 183-188


306-313: Refactored methods for volume control during speaking.

The methods _lower_volume_on_speak and _restore_volume_on_speak have been introduced, replacing the previous generic volume control methods. This more specific naming and functionality ensure clarity in the codebase and better manage the audio state during speech events.

Also applies to: 320-322


329-338: New method to handle volume restoration after utterance handling.

The method _restore_volume_on_handled is a significant addition. It ensures that the volume is restored correctly after an utterance is fully handled, addressing the issue described in the linked GitHub issue. This method checks if speech is not happening and restores the volume, which is crucial for maintaining user experience consistency.


341-351: Refactored method for volume control during recording.

The method _lower_volume_on_record has been refactored to handle volume reduction when recording starts. This is essential for preventing feedback and ensuring clear audio capture, which is particularly important in a voice-controlled environment.


Line range hint 399-423: Updated logic for selecting the audio player service based on URI type.

The updated logic in the play method for selecting the appropriate audio service based on the URI type and user preferences helps in maintaining a robust and flexible audio playback system. This change is crucial for ensuring that the correct backend is used for different media types, which can significantly affect playback quality and resource usage.


581-590: Updated shutdown method to remove event handlers.

The shutdown method has been updated to ensure that all event handlers related to audio service and volume control are properly removed. This is a good practice for cleaning up resources and preventing potential memory leaks or erroneous behavior after the service is stopped.

@JarbasAl JarbasAl merged commit a2567e5 into dev Jul 17, 2024
4 checks passed
@JarbasAl JarbasAl deleted the fix/ducking branch July 17, 2024 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong volume after ducking when restarting ocp
1 participant