Skip to content

Conversation

tuancoltech
Copy link
Member

@tuancoltech tuancoltech commented Apr 11, 2025

Remove the APIs for providing custom TTS language selection.

Relates to elimu-ai/vitabu#178

Summary by CodeRabbit

  • Refactor
    • Streamlined language handling by removing legacy conversion utilities and provider interfaces.
    • Simplified text-to-speech setup to rely solely on the application context, reducing complexity while maintaining core functionality.
  • Bug Fixes
    • Enhanced robustness in the speak method by preventing potential null pointer exceptions in logging.

@tuancoltech tuancoltech requested a review from a team as a code owner April 11, 2025 16:00
@tuancoltech tuancoltech requested a review from jo-elimu April 11, 2025 16:00
@tuancoltech tuancoltech self-assigned this Apr 11, 2025
@tuancoltech
Copy link
Member Author

@jo-elimu Could you help testing this issue using a new snapshot published from this PR's change, and let me know if TTS works for both debug and release build?
Somehow it's always working in my side even without these changes for both build variants.

Copy link

coderabbitai bot commented Apr 11, 2025

Walkthrough

This pull request removes language fallback functionality from the codebase. Specifically, it deletes the utility functions for converting between a custom Language enum and Java’s Locale (contained in LanguageExt.kt), as well as the DefaultLanguageProviderImpl class and the LanguageProvider interface. Additionally, the dependency on language providers in the text-to-speech module has been eliminated by simplifying the module and the TextToSpeechWrapper class to rely solely on the application context. This aligns with the goal of removing default language mappings.

elimu.ai's mission is to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months.

Changes

File(s) Change Summary
utils/src/main/java/ai/elimu/common/utils/LanguageExt.kt Removed functions (toLocale() and toLanguage()) for converting between custom Language enum values and Java’s Locale; eliminated fallback to default language.
utils/src/main/java/ai/elimu/common/utils/data/repository/DefaultLanguageProviderImpl.kt,
utils/src/main/java/ai/elimu/common/utils/data/repository/language/LanguageProvider.kt
Removed DefaultLanguageProviderImpl class and LanguageProvider interface, thereby deleting the methods getLanguage() and getContentProviderId().
utils/src/main/java/ai/elimu/common/utils/di/DataModule.kt Removed methods for providing language providers (both optional and standard) and updated the providesTextToSpeech method to remove the dependency on a language provider.
utils/src/main/java/ai/elimu/common/utils/di/TextToSpeechWrapper.kt Simplified the constructor by removing the contentProviderId parameter and the associated language-based configuration logic; retained text-to-speech initialization and error handling.
utils/src/main/java/ai/elimu/common/utils/data/repository/local/LocalTextToSpeechDataSourceImpl.kt Updated logging statement in speak method to prevent potential NullPointerException by using a safe call operator.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant DM as DataModule
    participant TTSW as TextToSpeechWrapper
    participant TTS as Android TextToSpeech Engine

    C->>DM: Request Text-to-Speech instance
    DM->>TTSW: Call providesTextToSpeech(context)
    TTSW->>TTS: Initialize Text-to-Speech with context
    TTS-->>TTSW: TTS initialization callback (success/failure)
    TTSW-->>DM: Return initialized TTS instance
    DM-->>C: Provide TTS instance for speech synthesis
Loading

Assessment against linked issues

Objective Addressed Explanation
Delete DefaultLanguageProviderImpl (#34)
Delete LanguageExt.kt (#35)
Delete getLanguage() and getContentProviderId() from LanguageProvider (#36, #37)

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ab636f and 9938e12.

📒 Files selected for processing (1)
  • utils/src/main/java/ai/elimu/common/utils/data/repository/local/LocalTextToSpeechDataSourceImpl.kt (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build (macos-latest, 21)
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: build (ubuntu-latest, 21)
🔇 Additional comments (1)
utils/src/main/java/ai/elimu/common/utils/data/repository/local/LocalTextToSpeechDataSourceImpl.kt (1)

18-18: Excellent use of the safe call operator! 📖✍🏽🔢

Great improvement by adding the Kotlin safe call operator (?.) to prevent potential NullPointerException when accessing the locale property of a potentially null voice object. This makes the logging more robust, which is especially important in an application focused on education.

In alignment with elimu.ai's mission to build innovative learning software that empowers out-of-school children to teach themselves basic reading📖, writing✍🏽 and math🔢 within 6 months, even small improvements in code quality contribute to the overall stability of the educational platform!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@jo-elimu
Copy link
Member

Could you help testing this issue using a new snapshot published from this PR's change, and let me know if TTS works for both debug and release build?
Somehow it's always working in my side even without these changes for both build variants.

@tuancoltech Sure. I guess this would involve adding mavenLocal() to build.gradle and then run a Gradle command? Would you mind adding the necessary steps for doing -SNAPSHOT testing to the README?

@tuancoltech
Copy link
Member Author

tuancoltech commented Apr 13, 2025

Could you help testing this issue using a new snapshot published from this PR's change, and let me know if TTS works for both debug and release build?
Somehow it's always working in my side even without these changes for both build variants.

@tuancoltech Sure. I guess this would involve adding mavenLocal() to build.gradle and then run a Gradle command?

@jo-elimu You are correct!

Would you mind adding the necessary steps for doing -SNAPSHOT testing to the README?

No problem. I've added the guidelines here: #43
Please help review it too!

@jo-elimu
Copy link
Member

No problem. I've added the guidelines here: #43

@tuancoltech I've followed the steps in the documentation, but getting this error:

./gradlew clean build
* What went wrong:
Execution failed for task ':app:dataBindingMergeDependencyArtifactsDebug'.
> Could not resolve all files for configuration ':app:debugCompileClasspath'.
   > Could not find com.github.elimu-ai:common-utils:1.0.10-SNAPSHOT.
     Required by:
         project :app

I already published the common-utils library to mavenLocal():

./gradlew clean utils:publishReleasePublicationToMavenLocal

And verified that the .aar file is available on the local computer:

~\.m2\repository\ai\elimu\common\utils\1.0.10-SNAPSHOT\utils-1.0.10-SNAPSHOT.aar

@tuancoltech
Copy link
Member Author

tuancoltech commented Apr 14, 2025

No problem. I've added the guidelines here: #43

@tuancoltech I've followed the steps in the documentation, but getting this error:

./gradlew clean build
* What went wrong:
Execution failed for task ':app:dataBindingMergeDependencyArtifactsDebug'.
> Could not resolve all files for configuration ':app:debugCompileClasspath'.
   > Could not find com.github.elimu-ai:common-utils:1.0.10-SNAPSHOT.
     Required by:
         project :app

I already published the common-utils library to mavenLocal():

./gradlew clean utils:publishReleasePublicationToMavenLocal

And verified that the .aar file is available on the local computer:

~\.m2\repository\ai\elimu\common\utils\1.0.10-SNAPSHOT\utils-1.0.10-SNAPSHOT.aar

@jo-elimu You should add mavenLocal() to app's repositories block in project's build.gradle file, in order to use the snapshot.

allprojects {
    repositories {
        google()
        maven {
            url "https://jitpack.io"
        }
        mavenCentral()
        mavenLocal()
    }
}

@jo-elimu jo-elimu mentioned this pull request Apr 14, 2025
10 tasks
@tuancoltech
Copy link
Member Author

@jo-elimu Could you help testing this issue using a new snapshot published from this PR's change, and let me know if TTS works for both debug and release build? Somehow it's always working in my side even without these changes for both build variants.

@jo-elimu Just a kind reminder: Please help verifying this once you have some free time!

@jo-elimu
Copy link
Member

You should add mavenLocal() to app's repositories block in project's build.gradle file, in order to use the snapshot.

@tuancoltech Yes, I followed the steps in your documentation and already added mavenLocal() in the app side, but getting this error:

Could not find com.github.elimu-ai:common-utils

@tuancoltech
Copy link
Member Author

tuancoltech commented Apr 16, 2025

You should add mavenLocal() to app's repositories block in project's build.gradle file, in order to use the snapshot.

@tuancoltech Yes, I followed the steps in your documentation and already added mavenLocal() in the app side, but getting this error:

Could not find com.github.elimu-ai:common-utils

@jo-elimu If you look closer on README on how to test the snapshot, the dependency should exactly be:

ai.elimu.common:utils:$snapshot_version

@jo-elimu
Copy link
Member

jo-elimu commented Apr 17, 2025

@tuancoltech Okay, I got it working now. Had to also change the groupId and groupName in libs.version.toml:

-elimuCommonutils = "1.0.7"
+elimuCommonutils = "1.0.10-SNAPSHOT"
-elimu-common-utils = { group = "com.github.elimu-ai", name = "common-utils", version.ref = "elimuCommonutils" }
+elimu-common-utils = { group = "ai.elimu.common", name = "utils", version.ref = "elimuCommonutils" }

@tuancoltech tuancoltech merged commit 781a0c6 into main Apr 17, 2025
6 checks passed
@tuancoltech tuancoltech deleted the remove_custom_tts_language_api branch April 17, 2025 08:42
@coderabbitai coderabbitai bot mentioned this pull request Apr 30, 2025
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants