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

feat:g2p #109

Merged
merged 4 commits into from
Oct 23, 2024
Merged

feat:g2p #109

merged 4 commits into from
Oct 23, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 23, 2024

move the G2P plugin from TTS base class into ovos-audio

it was only there originally as a way to deploy it to classic mycroft-core when they didn't review PRs

companion to OpenVoiceOS/ovos-plugin-manager#277

Summary by CodeRabbit

  • New Features
    • Introduced a new optional plugin for generating visemes during audio playback.
  • Bug Fixes
    • Improved error handling for loading the viseme generation plugin and during viseme generation.
  • Refactor
    • Simplified the shutdown process for the audio playback service, enhancing management of the playback thread.

move the G2P plugin from TTS base class into ovos-audio

it was only there originally as a way to deploy it to classic mycroft-core when they didn't review PRs
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Walkthrough

The changes in this pull request focus on enhancing the PlaybackThread class in ovos_audio/playback.py by adding a new optional attribute for Grapheme2Phoneme processing and improving the _play method to generate visemes. Additionally, the shutdown method in the PlaybackService class in ovos_audio/service.py has been updated to terminate the playback_thread instead of the previous tts.playback object, reflecting a shift in audio playback management.

Changes

File Change Summary
ovos_audio/playback.py - Added optional attribute g2p to PlaybackThread for Grapheme2Phoneme plugin.
- Updated _play method to generate visemes using g2p, with error handling for exceptions.
- Simplified run method by removing deprecated checks and directly unpacking queue data.
ovos_audio/service.py - Modified shutdown method in PlaybackService to shut down playback_thread instead of tts.playback.

Possibly related PRs

  • fix:b64 improvements #107: The changes in this PR involve modifications to the PlaybackService class in ovos_audio/service.py, which is directly related to the PlaybackThread class in the main PR, as both are involved in managing audio playback functionality.

Suggested reviewers

  • goldyfruit
  • mikejgray
  • builderjer

Poem

In the burrow where sounds take flight,
A thread of playback, shining bright.
With g2p to guide, visemes in tow,
Our audio dance begins to flow.
So hop along, let the music play,
For every change brings a joyful day! 🐇🎶


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.

move the G2P plugin from TTS base class into ovos-audio

it was only there originally as a way to deploy it to classic mycroft-core when they didn't review PRs
JarbasAl added a commit to OpenVoiceOS/ovos-config that referenced this pull request Oct 23, 2024
reduce default LOG spam

companion to OpenVoiceOS/ovos-audio#109
move the G2P plugin from TTS base class into ovos-audio

it was only there originally as a way to deploy it to classic mycroft-core when they didn't review PRs
@github-actions github-actions bot added feature and removed feature labels Oct 23, 2024
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: 3

🧹 Outside diff range and nitpick comments (2)
ovos_audio/playback.py (1)

35-41: Consider adding documentation for G2P configuration.

The G2P integration is well-implemented as an optional feature, but it would benefit from:

  1. Documentation of the expected configuration format
  2. Example configuration in the README
  3. Documentation of the fallback behavior when G2P is unavailable

This will help users understand how to properly configure and use the G2P functionality for viseme generation.

Would you like me to help draft the documentation?

🧰 Tools
🪛 Ruff

38-41: Use contextlib.suppress(Exception) instead of try-except-pass

(SIM105)


40-40: Do not use bare except

(E722)

ovos_audio/service.py (1)

Line range hint 1-586: Architecture aligns with G2P integration goals.

The existing G2P related methods (get_g2p_lang_options, handle_opm_g2p_query) in this file show that this was a well-planned migration. Moving the G2P plugin from TTS base class to ovos-audio module is architecturally sound as:

  1. It consolidates audio-related functionality in one place
  2. The file already handles G2P configurations and queries
  3. It maintains clean separation of concerns between TTS and audio processing
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 248b0aa and 93671e5.

📒 Files selected for processing (2)
  • ovos_audio/playback.py (4 hunks)
  • ovos_audio/service.py (1 hunks)
🧰 Additional context used
🪛 Ruff
ovos_audio/playback.py

10-10: ovos_plugin_manager.g2p.find_g2p_plugins imported but unused

Remove unused import: ovos_plugin_manager.g2p.find_g2p_plugins

(F401)


38-41: Use contextlib.suppress(Exception) instead of try-except-pass

(SIM105)


40-40: Do not use bare except

(E722)


139-139: Do not use bare except

(E722)

🔇 Additional comments (2)
ovos_audio/playback.py (1)

180-180: LGTM: Clean queue data handling.

The simplified queue data unpacking is clear and consistent with the PR's refactoring objectives.

ovos_audio/service.py (1)

560-562: Ensure proper thread cleanup in shutdown sequence.

The changes look good and align with the PR objective. The shutdown sequence correctly:

  1. Checks if playback_thread exists before attempting shutdown
  2. Calls shutdown on the thread
  3. Waits for thread completion with join()

This ensures clean termination of the G2P functionality that was moved from the TTS base class.

Let's verify there are no lingering references to the old tts.playback shutdown:

✅ Verification successful

Let me gather more information about the playback thread shutdown by searching for related patterns.

This will help us verify:

  1. The current implementation of playback thread shutdown
  2. Any remaining references to TTS playback
  3. The overall context of the PlaybackService class

Based on the search results, I can see that there are still references to tts.playback in the codebase, particularly in ovos_audio/service.py. Let me search for more context around these usages to understand if they're related to the shutdown sequence.

This will help us understand:

  1. The complete context of tts.playback usage
  2. How the playback thread is initialized and managed
  3. The relationship between tts.playback and playback_thread

Let me check one more thing to understand the relationship between the old and new playback implementations.

This will help us understand:

  1. How the shutdown is implemented in PlaybackThread
  2. The initialization flow of playback
  3. The queue handling mechanism during shutdown

Based on the gathered information, I can now provide a final response about the shutdown sequence verification.

The shutdown sequence is correctly implemented and maintains compatibility

The changes to the shutdown sequence are verified to be correct for the following reasons:

  1. The PlaybackThread has a proper shutdown() implementation that calls stop() (found in playback.py:227)
  2. The references to tts.playback in the codebase are for different purposes (status checking and clearing) and don't conflict with the shutdown sequence
  3. The shutdown order is correct:
    • First checks if playback_thread exists
    • Calls shutdown() which internally handles stopping playback
    • Properly joins the thread
    • Then proceeds with audio shutdown

The existing tts.playback references are used for runtime operations (like checking if audio is playing or clearing current playback) and are separate from the shutdown functionality that was moved to the PlaybackThread.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to tts.playback shutdown
rg "tts\.playback.*shutdown" --type py

Length of output: 40


Script:

#!/bin/bash
# Search for playback thread shutdown patterns
rg "playback_thread.*shutdown" -A 2 --type py

# Search for any TTS playback related patterns
rg "tts.*playback" -A 2 --type py

# Look for the PlaybackService class definition to understand the context
ast-grep --pattern 'class PlaybackService:
  $$$
'

Length of output: 1716


Script:

#!/bin/bash
# Get more context around tts.playback usage in service.py
rg "tts\.playback" -B 2 -A 2 ovos_audio/service.py

# Look for the playback thread initialization
rg "playback_thread.*=|PlaybackThread" --type py -B 2 -A 2

# Search for the PlaybackThread class definition
ast-grep --pattern 'class PlaybackThread:
  $$$
'

Length of output: 2237


Script:

#!/bin/bash
# Look for the shutdown method implementation in PlaybackThread
ast-grep --pattern 'def shutdown(self):
  $$$
' --lang python

# Check for any TTS initialization related to playback
rg "init.*playback" -B 2 -A 2 --type py

# Look for any queue-related operations in playback
rg "queue\." -B 2 -A 2 ovos_audio/playback.py

Length of output: 5785

ovos_audio/playback.py Outdated Show resolved Hide resolved
ovos_audio/playback.py Show resolved Hide resolved
ovos_audio/playback.py Show resolved Hide resolved
JarbasAl added a commit to OpenVoiceOS/ovos-config that referenced this pull request Oct 23, 2024
reduce default LOG spam

companion to OpenVoiceOS/ovos-audio#109
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@JarbasAl JarbasAl merged commit c782ad0 into dev Oct 23, 2024
5 checks passed
@JarbasAl JarbasAl deleted the feat/g2p branch October 23, 2024 21:55
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