Feature: Dual Voice Transcription System with Settings Interface Objective: Add Telegram Bot API transcription as a second option alongside existing Nexara API, with global configuration setting
π― Developer Tool Context: This is a developer tool application. Users are developers who understand technical concepts and can handle direct error messages without excessive hand-holding.
- Existing System: VoiceMessageHandler.js with Nexara API integration
- Architecture: Single transcription method with test mode fallback
- User Flow: Voice β Transcribe β Confirm/Cancel/Edit β Execute
- Configuration: Uses existing
configs/bot1.jsonsystem
- Dual Transcription Adapters: Nexara API + Telegram Bot API
- Settings Interface: Global transcription method selection
- Simple Error Handling: Direct API error messages (no fallbacks)
- Config Integration: Use existing configuration system
TranscriptionAdapterInterface
βββ NexaraTranscriptionAdapter (existing logic)
βββ TelegramTranscriptionAdapter (new)
βββ TestTranscriptionAdapter (unit tests only)
Benefits:
- Clean separation of concerns
- Simple to maintain for developers
- Testable architecture
- Direct error propagation
Global Setting in configs/bot1.json:
{
"voiceTranscriptionMethod": "nexara", // "nexara" | "telegram"
// ... existing config fields
}Default: "nexara" (preserves existing behavior)
VoiceMessageHandler (Enhanced)
βββ Adapter selection from config
βββ Direct error handling (no fallbacks)
βββ Simple method switching
βββ Developer-friendly error messages
βοΈ Settings
βββ π€ Voice Transcription Method
β βββ π‘ Telegram API
β βββ π§ Nexara API (Current)
βββ π Back to Main Menu
- Simple Options:
- "Telegram API"
- "Nexara API"
- Current Selection Display: Show active method
- Direct Configuration: Immediate config file update
Status: β³ Planned
Tasks:
- Create
TranscriptionAdapterInterfacebase class - Refactor existing Nexara code into
NexaraTranscriptionAdapter - Create
TestTranscriptionAdapterfor unit tests only - Update
VoiceMessageHandlerto use adapter pattern - Add config reading for transcription method selection
Files to Create/Modify:
adapters/TranscriptionAdapterInterface.js(new)adapters/NexaraTranscriptionAdapter.js(new)adapters/TestTranscriptionAdapter.js(new - tests only)VoiceMessageHandler.js(modify)
Status: β³ Planned
Tasks:
- Implement
TelegramTranscriptionAdapter - Handle Telegram Bot API transcription requests
- Direct error handling from Telegram API
- Integration with existing voice flow
Files to Create/Modify:
adapters/TelegramTranscriptionAdapter.js(new)
Status: β³ Planned
Tasks:
- Create settings menu interface
- Add settings callbacks to main bot
- Implement transcription method selection UI
- Config file update mechanism
Files to Create/Modify:
SettingsMenuHandler.js(new)bot.js(modify - add settings callbacks)
Status: β³ Planned
Tasks:
- TDD implementation of all components
- Integration testing
- Fix existing tests broken by changes
- Documentation updates
Files to Create/Modify:
tests/unit/transcription-adapters.test.js(new)tests/unit/voice-message-handler.test.js(modify existing)- Update other affected tests
Implementation Approach:
// Pseudo-code for Telegram transcription
async transcribeWithTelegram(fileId) {
try {
// Use Telegram Bot API to transcribe voice message
const result = await this.bot.transcribeAudio(fileId);
return result.text;
} catch (error) {
// Direct error propagation to user
throw new Error(`Telegram transcription failed: ${error.message}`);
}
}Reading Config:
getTranscriptionMethod() {
const config = JSON.parse(fs.readFileSync(this.configFilePath, 'utf8'));
return config.voiceTranscriptionMethod || 'nexara'; // default
}Updating Config:
setTranscriptionMethod(method) {
const config = JSON.parse(fs.readFileSync(this.configFilePath, 'utf8'));
config.voiceTranscriptionMethod = method;
fs.writeFileSync(this.configFilePath, JSON.stringify(config, null, 2));
}Direct Error Messages (no fallbacks):
- Telegram API unavailable β show Telegram error message
- Nexara API key missing β show "Nexara API key not configured"
- Network errors β show network error details
- Invalid method β show configuration error
createTranscriptionAdapter() {
const method = this.getTranscriptionMethod();
switch (method) {
case 'telegram':
return new TelegramTranscriptionAdapter(this.bot);
case 'nexara':
default:
return new NexaraTranscriptionAdapter(this.nexaraApiKey);
}
}- Write tests first for each component
- Implement functionality to pass tests
- Fix existing tests broken by changes
- Maintain test coverage throughout development
- Each adapter tested independently
- Settings configuration changes
- Error handling scenarios
- Config file read/write operations
- End-to-end voice message flow with both adapters
- Settings UI interactions
- Error propagation through the system
As a developer, I want to access transcription settings easily
Given I'm using the bot
When I type /settings or use a settings command
Then I see transcription method options
As a developer, I want to choose Telegram API for transcription Given I access settings When I select "Telegram API" Then my voice messages use Telegram's transcription service
As a developer, I want clear error messages when transcription fails Given I'm using a transcription method that fails When I send a voice message Then I see the exact error from the API (no fallbacks)
As a developer, I want my transcription method choice to persist Given I've selected a transcription method When I restart the bot or send messages later Then my choice is maintained in the config file
- Two transcription adapters working independently
- Settings interface accessible via bot commands
- Global preference saved in
configs/bot1.json - Direct error handling (no fallbacks)
- TDD implementation with full test coverage
- Response time similar to current implementation
- Settings changes take effect immediately
- Error messages are direct and technical (appropriate for developers)
- Code maintains test coverage
- Integration with existing config system
- Settings menu is accessible and functional
- Transcription method selection is clear
- Current method is displayed
- Config file updates work correctly
Add to configs/bot1.json:
{
"voiceTranscriptionMethod": "nexara",
// ... existing fields remain unchanged
}- No fallbacks: If selected method fails, show error
- Developer-friendly: Technical error messages are acceptable
- Direct API errors: Pass through actual API error messages
- Simple troubleshooting: Clear indication of what went wrong
- TDD mandatory: Tests written before implementation
- Fix broken tests: Update existing tests affected by changes
- Component isolation: Each adapter testable independently
- Integration coverage: Full voice message flow testing
This simplified plan provides a straightforward approach for implementing dual voice transcription:
- Minimal Complexity: Two adapters, simple config, direct errors
- Developer-Focused: Technical users can handle direct error messages
- Existing Integration: Uses current config system
- TDD Approach: Test-driven development throughout
- No Over-Engineering: Focused on core requirements only
Next Steps: Get approval for this simplified plan and begin Phase 1 implementation with TDD approach.