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:deprecate G2P #277

Merged
merged 2 commits into from
Oct 23, 2024
Merged

fix:deprecate G2P #277

merged 2 commits into from
Oct 23, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Oct 23, 2024

a companion PR will move it to ovos-audio

it is just spammy and unused outside mk1

Summary by CodeRabbit

  • New Features
    • Introduced a new property for managing G2P functionality within the TTS class.
  • Bug Fixes
    • Removed deprecated methods and properties related to G2P, streamlining the TTS implementation.
    • Added deprecation warnings for outdated methods and properties, guiding users to updated practices.

a companion PR will move it to ovos-audio

it is just spammy and unused outside mk1
@JarbasAl JarbasAl requested review from goldyfruit and j1nx October 23, 2024 19:23
Copy link
Contributor

coderabbitai bot commented Oct 23, 2024

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Files that changed from the base of the PR and between bb81f25 and ef6be89.

📒 Files selected for processing (1)
  • ovos_plugin_manager/g2p.py (1 hunks)
_________________________________________________________________
< This is Sparta! And I'm here to kick bugs into the pit of doom. >
-----------------------------------------------------------------
 \
  \   (\__/)
      (•ㅅ•)
      /   づ

Walkthrough

The pull request introduces significant modifications to the tts.py file in the ovos_plugin_manager/templates directory. It removes deprecated grapheme-to-phoneme (G2P) methods and introduces a new g2p property in the TTS class, which issues deprecation warnings. Methods previously using G2P functionality are updated to eliminate G2P references, while deprecation warnings are added for other outdated properties and methods. The constructor of the TTS class is also updated to log deprecated parameters, streamlining the TTS implementation by removing outdated dependencies.

Changes

File Change Summary
ovos_plugin_manager/templates/tts.py - Added g2p property and setter in TTS class.
- Removed _init_g2p and _cache_phonemes methods.
- Updated methods to remove G2P references.
- Added deprecation warnings for various properties and methods.

Possibly related PRs

  • fix/restore_dead_code #256: The changes in this PR also involve the deprecation of methods within the TTS class in tts.py, which aligns with the main PR's focus on removing deprecated G2P methods and introducing deprecation warnings for other properties and methods.

Suggested labels

bug, documentation

Poem

🐰 In the land of TTS, changes abound,
G2P has left, no longer around.
With warnings in place, we clear the way,
For a brighter tomorrow, come what may!
Hop along, dear friends, let’s celebrate,
A cleaner codebase, oh isn’t it great? 🌟


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 fix and removed fix 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: 0

🧹 Outside diff range and nitpick comments (2)
ovos_plugin_manager/templates/tts.py (2)

Line range hint 664-675: Remove the _cache_phonemes method to align with G2P deprecation

The method _cache_phonemes is still present in the TTS class, even though G2P functionality has been deprecated and moved to ovos-audio. Keeping this method may cause confusion or unintended dependencies on deprecated functionality. It would be prudent to remove this method to fully encapsulate the deprecation.

Apply this diff to remove the _cache_phonemes method:

-    def _cache_phonemes(self, sentence, lang: str, cache: TextToSpeechCache = None, phonemes=None, sentence_hash=None):
-        """
-        Caches phonemes for the given sentence.
-
-        Args:
-            sentence (str): The sentence to cache phonemes for.
-            cache (TextToSpeechCache): The cache instance.
-            phonemes (str, optional): The phonemes for the sentence.
-            sentence_hash (str, optional): The hash of the sentence.
-        """
-        sentence_hash = sentence_hash or hash_sentence(sentence)
-        if phonemes:
-            phoneme_file = cache.define_phoneme_file(sentence_hash)
-            phoneme_file.save(phonemes)
-            return phoneme_file
-        return None

Line range hint 1026-1038: Ensure deprecated classes are properly marked and alternatives provided

Classes like PlaybackThread and RemoteTTS are marked for deprecation with upcoming removal. Make sure that all references to these classes in the codebase are updated to use their replacements. Additionally, confirm that any external documentation or examples are updated to guide users towards the new implementations.

Consider adding deprecation warnings within these classes to alert users at runtime:

 class PlaybackThread(Thread):
     """ PlaybackThread moved to ovos_audio.playback
     standalone plugin usage should rely on self.get_tts
     ovos-audio relies on self.execute and needs this class

     this class was only in ovos-plugin-manager in order to
     patch usage of our plugins in mycroft-core"""
+    def __init__(self, *args, **kwargs):
+        log_deprecation("PlaybackThread has been deprecated and will be removed in future releases. Please use the equivalent from ovos_audio.playback.", "1.0.0")
+        super().__init__(*args, **kwargs)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 6ec7ea1 and bb81f25.

📒 Files selected for processing (1)
  • ovos_plugin_manager/templates/tts.py (1 hunks)
🧰 Additional context used
🔇 Additional comments (2)
ovos_plugin_manager/templates/tts.py (2)

233-241: Deprecation of g2p property is properly handled

The addition of the g2p property and its setter correctly logs deprecation warnings, indicating that G2P functionality has moved to PlaybackThread in ovos-audio. Accessing or setting g2p will inform users of this change without disrupting the current workflow.


Line range hint 531-537: Verify viseme generation without G2P dependencies

The _get_visemes method now relies solely on the phonemes provided by self.get_tts. Since G2P functionality has been deprecated, ensure that all TTS plugins supply phoneme data as needed. This change could impact viseme generation if phonemes are not available from the TTS engine.

Run the following script to identify TTS plugins that do not provide phoneme data:

✅ Verification successful

Let me try a different approach to verify this concern by searching for TTS plugins and their phoneme handling.


Let me try one more search focusing on the template and base class implementation to understand the phoneme handling requirements.


Based on the code analysis, I can now provide a final response about the viseme generation concern.

Viseme generation is safely handled with or without phoneme data

The code shows that the _get_visemes method is designed to handle both cases where phonemes are available or not:

  • If phonemes are provided by the TTS engine, they are converted to visemes using the viseme() method
  • If phonemes are not available, an empty viseme list is returned with a debug log
  • The StreamingTTS base class explicitly documents that it doesn't support phonemes and returns None
  • The caching system properly handles both audio and phoneme data independently

No changes are required as the system gracefully handles TTS plugins that don't provide phoneme data.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find TTS plugins that lack phoneme support.

# Test: Search for TTS plugins without `phonemes` in their `get_tts` return statement.
# Expectation: Identify plugins that need updates to provide phoneme data.

fd -e py 'get_tts' ovos_tts_plugins/ | xargs grep -L 'return.*,.*phoneme'

Length of output: 195


Script:

#!/bin/bash
# First, let's find where TTS plugins are located in the repository
fd -t d "tts"

# Then let's examine the base TTS class implementation
rg -A 5 "class TTSPlugin" 

# And look for get_tts method implementations
ast-grep --pattern 'def get_tts(self, sentence, lang, *args, **kwargs):
    $$$
'

Length of output: 125


Script:

#!/bin/bash
# Look for the base TTS class and get_tts method in the templates
rg -A 10 "class TTS" ovos_plugin_manager/templates/tts.py

# Search for phoneme-related code in the TTS template
rg -B 5 -A 5 "phoneme" ovos_plugin_manager/templates/tts.py

# Look for viseme-related code
rg -B 5 -A 5 "_get_visemes" ovos_plugin_manager/templates/tts.py

Length of output: 12336

@JarbasAl
Copy link
Member Author

companion PR OpenVoiceOS/ovos-audio#109

@JarbasAl JarbasAl merged commit c102889 into dev Oct 23, 2024
8 checks passed
@JarbasAl JarbasAl deleted the fix/g2p_spam branch October 23, 2024 19:47
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