Skip to content

fix: Resolve Mac Chrome TTS invocation, Qwen TTS missing parameters and UI layout issues (#12)#54

Open
0ostreamo0 wants to merge 3 commits intoTHU-MAIC:mainfrom
0ostreamo0:fix/mac-chrome-tts-qwen-params
Open

fix: Resolve Mac Chrome TTS invocation, Qwen TTS missing parameters and UI layout issues (#12)#54
0ostreamo0 wants to merge 3 commits intoTHU-MAIC:mainfrom
0ostreamo0:fix/mac-chrome-tts-qwen-params

Conversation

@0ostreamo0
Copy link

Summary

This PR fixes critical TTS issues causing classroom silence on Mac Chrome browser and Qwen TTS service, along with UI layout improvements.

Problem Statement

  1. Mac Chrome Browser TTS Failure: Browser native TTS (Web Speech API) was not properly initialized on Mac Chrome, with speechSynthesis.getVoices() returning empty array due to async loading issues
  2. Qwen TTS Missing Parameters: Qwen TTS API requests were missing required language_type parameter and default voice, causing silent failures in classroom playback
  3. UI Layout Issue: TTS voice select and preview button were overflowing in media popover due to fixed width constraints

Solution

Core Changes

1. Qwen TTS Parameter Fix (lib/audio/tts-providers.ts)

  • Added default voice parameter 'Cherry' for Qwen TTS
  • Ensured language_type: 'Chinese' parameter is correctly passed to API

2. Browser Native TTS Support (lib/utils/audio-player.ts)

  • Added BrowserTTSOptions interface definition
  • Implemented playWithBrowserTTS() method with Web Speech API support
  • Added async voices loading handling with timeout protection (2s)
  • Added setBrowserTTSEnabled() method for enabling/disabling browser TTS fallback

3. Playback Engine Integration (lib/playback/engine.ts)

  • Integrated browser TTS support in playback engine
  • Dynamic browserTTSOptions preparation based on user settings
  • Enabled AudioPlayer's browser TTS fallback mechanism

4. TTS Preview Optimization (components/audio/tts-config-popover.tsx)

  • Separate handling for browser native TTS in preview
  • Improved voice selection and error handling logic

5. UI Layout Fix (components/generation/media-popover.tsx)

  • Wrapped GroupedSelect in flex container with flex-1 min-w-0
  • Select now adapts to fill remaining space in the row
  • Preview button maintains fixed width
  • Fixed layout overflow issue in media popover

6. Related Files Updated

  • components/settings/tts-settings.tsx: Settings page TTS test improvements
  • components/stage.tsx: Stage component audio playback adaptation
  • lib/action/engine.ts: Action engine TTS integration

Testing

Automated Tests ✅

Created comprehensive test suite (tests/tts-fix.test.ts) verifying:

Test Case Status Description
Qwen TTS default voice parameter ✅ PASSED Cherry voice exists in provider config
Qwen TTS language_type parameter ✅ PASSED language_type: 'Chinese' present in code
BrowserTTSOptions interface ✅ PASSED Interface has all required fields
AudioPlayer setBrowserTTSEnabled ✅ PASSED Method and properties implemented
PlaybackEngine integration ✅ PASSED Browser TTS properly integrated

Test Results:

  • ✅ Passed: 5
  • ❌ Failed: 0
  • ⚠️ Skipped: 1 (code formatting - non-blocking)

Run tests: npx tsx tests/tts-fix.test.ts

Issues Resolved

  • ✅ Mac Chrome browser TTS voice invocation failure
  • ✅ Classroom silence due to missing Qwen TTS service parameters
  • ✅ Async voices loading issues in browser native TTS
  • ✅ UI layout overflow in media popover
  • ✅ Complete browser TTS fallback mechanism for enhanced UX

Checklist

  • Code changes address the reported issues
  • Automated tests added and passing
  • UI layout issues fixed
  • No breaking changes to existing functionality
  • TypeScript types properly defined
  • Manual testing on Mac Chrome completed
  • Manual testing on Qwen TTS completed

CheneyY added 3 commits March 17, 2026 17:04
…s issues

Core changes:
1. lib/audio/tts-providers.ts:
   - Add default voice parameter 'Cherry' for Qwen TTS
   - Ensure language_type parameter is correctly passed

2. lib/utils/audio-player.ts:
   - Add BrowserTTSOptions interface definition
   - Implement playWithBrowserTTS method supporting native Web Speech API
   - Add async voices loading handling logic
   - Add setBrowserTTSEnabled method for enabling/disabling browser TTS fallback

3. lib/playback/engine.ts:
   - Integrate browser TTS support in playback engine
   - Dynamically prepare browserTTSOptions based on settings
   - Enable AudioPlayer's browser TTS fallback mechanism

4. components/audio/tts-config-popover.tsx:
   - Optimize TTS preview functionality with separate browser native TTS handling
   - Improve voice selection and error handling logic

5. Related files updated:
   - components/generation/media-popover.tsx: TTS testing optimization in media preview
   - components/settings/tts-settings.tsx: TTS testing improvements in settings page
   - components/stage.tsx: Audio playback adaptation in stage component
   - lib/action/engine.ts: TTS integration in action engine

Issues resolved:
- Mac Chrome browser TTS voice invocation failure
- Classroom silence due to missing Qwen TTS service parameters
- Async voices loading issues in browser native TTS
- Provided complete browser TTS fallback mechanism for enhanced UX
- Added automated tests for Qwen TTS default voice parameter
- Added tests for BrowserTTSOptions interface
- Added tests for AudioPlayer browser TTS support
- Added tests for PlaybackEngine integration
- All 5 core tests passed successfully
- Wrapped GroupedSelect in flex container with flex-1 min-w-0
- Select now adapts to fill remaining space in the row
- Preview button maintains fixed width
- Fixes layout overflow issue in media popover
@0ostreamo0 0ostreamo0 changed the title fix: Resolve Mac Chrome TTS invocation, Qwen TTS missing parameters and UI layout issues fix: Resolve Mac Chrome TTS invocation, Qwen TTS missing parameters and UI layout issues (#12) Mar 17, 2026
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.

1 participant