Skip to content

Conversation

tuancoltech
Copy link
Member

@tuancoltech tuancoltech commented Apr 3, 2025

Wrong TTS language locale conversion.

Related to elimu-ai/vitabu#177

Summary by CodeRabbit

  • Chores
    • Updated internal versioning to support ongoing improvements.
  • Refactor
    • Streamlined the text-to-speech language selection process for enhanced reliability.

@tuancoltech tuancoltech requested a review from a team as a code owner April 3, 2025 01:10
@tuancoltech tuancoltech force-pushed the bug/tts_wrong_language_locale_conversion branch from 7ae5280 to 06ce844 Compare April 3, 2025 01:11
Copy link

coderabbitai bot commented Apr 3, 2025

Walkthrough

This pull request updates the library version information in the Gradle build configuration and refines the language selection logic in the TextToSpeechWrapper class. The build file now uses libVersion = '1.0.6-SNAPSHOT' and updates versionCode to 1000006. In the TextToSpeechWrapper, the language assignment is simplified using the ifEmpty function to choose between a provided language and a default language, while the error handling remains unchanged.

Changes

File(s) Change Summary
utils/build.gradle Updated libVersion from '1.0.5-SNAPSHOT' to '1.0.6-SNAPSHOT' and versionCode from 1000005 to 1000006.
utils/.../TextToSpeechWrapper.kt Simplified the language selection logic by using ifEmpty to choose between language and contentProviderLanguage.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant TextToSpeechWrapper
    participant TTS_Engine

    Caller->>TextToSpeechWrapper: Initialize with language & contentProviderLanguage
    TextToSpeechWrapper->>TextToSpeechWrapper: sttLanguage = language.ifEmpty(contentProviderLanguage)
    TextToSpeechWrapper->>TTS_Engine: setLanguage(sttLanguage.toLowerCase())
Loading

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • jo-elimu
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 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.

Copy link

@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

🧹 Nitpick comments (1)
utils/src/main/java/ai/elimu/common/utils/di/TextToSpeechWrapper.kt (1)

38-42: Improved language selection with misleading variable name.

The language selection logic is now more concise with the ifEmpty function, which is a good improvement. However, the variable name sttLanguage is misleading in a Text-to-Speech (TTS) context as "STT" typically refers to "Speech-to-Text".

- val sttLanguage = language.ifEmpty {
+ val ttsLanguage = language.ifEmpty {
    contentProviderLanguage
}
- tts.setLanguage(sttLanguage.lowercase().toLanguage().toLocale())
+ tts.setLanguage(ttsLanguage.lowercase().toLanguage().toLocale())
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b3b38f4 and 06ce844.

📒 Files selected for processing (2)
  • utils/build.gradle (2 hunks)
  • utils/src/main/java/ai/elimu/common/utils/di/TextToSpeechWrapper.kt (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (windows-latest, 17)
🔇 Additional comments (3)
utils/src/main/java/ai/elimu/common/utils/di/TextToSpeechWrapper.kt (1)

42-42: Proper language locale handling for TTS.

The addition of lowercase() before calling toLanguage().toLocale() ensures consistent language code formatting, which helps resolve locale conversion issues. This appears to directly address the "Wrong TTS language locale conversion" problem mentioned in the PR title.

utils/build.gradle (2)

10-10: Version incremented appropriately for bug fix.

The library version has been properly incremented from '1.0.5-SNAPSHOT' to '1.0.6-SNAPSHOT' following semantic versioning conventions for a patch release.


21-21: Version code updated consistently with semantic version.

The version code has been updated from 1000005 to 1000006, maintaining consistency with the semantic version 1.0.6.

} else {
tts.setLanguage(contentProviderLanguage.toLanguage().toLocale())

val sttLanguage = language.ifEmpty {
Copy link
Member

@jo-elimu jo-elimu Apr 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tuancoltech The language variable here should probably be removed as a parameter? (Since the apps using this utils library don't know which language to use.)

class TextToSpeechWrapper(context: Context, language: String, contentProviderId: String)

class TextToSpeechWrapper(context: Context, contentProviderId: String)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jo-elimu The language parameter here is for apps to be able to pass a custom TTS language to the TextToSpeech engine, disregard the one selected in ContentProvidre.
It's for the future.

@tuancoltech tuancoltech merged commit 30c6c19 into main Apr 3, 2025
6 checks passed
@tuancoltech tuancoltech deleted the bug/tts_wrong_language_locale_conversion branch April 3, 2025 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants