feat: integrate TTS voice responses and improve response loading UX#44
Merged
Conversation
fix: resolve formatting issues and NLP sentiment detection crash
fix: resolve language preference not applied in conversation responses
Fix ConversationHandler & Expand Emotion Triggers
Introduce voice-language and RVC-based voice features across the app. Adds a new DB migration (migrate_add_voice_language.py) and adds voice_language column to the User model (database/models.py); also updates the existing migration for voice_enabled. DatabaseManager gained getters/setters for user voice language and refactors for user creation/message saving. Core changes: settings reorganized, NLPEngine made resilient when transformers/torch are unavailable, Application now initializes a VoiceProcessor (when enabled) and registers VoiceHandler. Commands and responses updated to expose /voicelang and interactive language selection (callbacks), and new libs/rvc_python plus utility helpers were added. Run the new migration script from project root to update the database before enabling voice features.
Move voice generation to an external TTS microservice and remove the bundled rvc_python library. Key changes: - .env.example: add TTS_SERVICE_URL, reorganize voice/NLP/DB settings and defaults. - README: document new Alya-TTS microservice-based voice setup and update voice feature text. - Removed libs/rvc_python package and related API/CLI/config files to stop bundling RVC internals. - Added utils/tts_queue.py and integrated dispatching to queue TTS jobs rather than inlining heavy audio work. - handlers/voice.py: refactored to translate and dispatch TTS via the queue, use DEFAULT_LANGUAGE, and avoid direct file-based TTS handling. - handlers/conversation.py & core/bot.py: removed inline voice processing from conversation flow and updated handler wiring. - database/database_manager.py: get_user_voice_language now falls back to user's language_code when voice_language is unset. - handlers/admin.py: removed deployment manager/status command and cleaned up registration/logging. - handlers/response/lang.py & handlers/commands.py: trimmed supported languages and updated voicelang labels. - core/nlp.py: clarified torch <2.6 warning message. Overall this refactor isolates audio workloads to a microservice, simplifies the bot code, and removes the bundled RVC implementation in favor of a separate TTS service and queued processing.
feat: add animated loading placeholder for AI response generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This Pull Request introduces two major improvements to the bot:
These changes significantly improve the responsiveness and interaction quality of the bot, especially for longer AI responses and voice generation workflows.
The update also includes internal refactoring to simplify loading animations, improve maintainability, and support asynchronous processing more reliably.
Key Improvements
Voice Response (TTS Integration)
The bot now supports voice responses through an external Alya-TTS microservice.
Key capabilities include:
Additional improvements:
Animated Loading UX
The bot now sends an initial placeholder message while waiting for AI responses instead of relying only on Telegram’s default typing indicator.
This loading message updates dynamically while the response is being generated, providing users with immediate feedback that processing is in progress.
This behavior applies to multiple interaction types:
Technical Improvements
Centralized Loading Animation Helper
All loading animation logic has been consolidated into a shared helper function:
start_loading_animation()Location:
utils/telegram_helpers.pyThis removes duplicated animation loops across handlers and ensures consistent behavior across the application.
Async Task Lifecycle Protection
A global set is used to maintain strong references to active animation tasks. This prevents Python’s garbage collector from terminating background animations prematurely.
_active_animationsTelegram Rate Limit Handling
Animation updates now properly handle Telegram flood limits by respecting the
Retry-Afterheader when the API rate limit is reached.TTS Microservice Payload Support
Voice generation requests now include:
loading_message_idThis allows the Alya-TTS microservice to delete the loading placeholder before sending the final voice message to the user.
Refactoring
Several components were refactored to improve modularity and maintainability:
Files Affected
Major updates were made to the following components:
handlers/conversation.pyhandlers/voice.pyutils/analyze.pyutils/roast.pyutils/telegram_helpers.pyutils/tts_queue.pyDeployment Notes
The Alya-TTS microservice must be restarted after deployment to apply the updated request payload schema.