chatGPTBox icon indicating copy to clipboard operation
chatGPTBox copied to clipboard

Add OpenAI TTS support to replace system text-to-speech with high-quality AI voices

Open Copilot opened this issue 6 months ago • 0 comments

This PR implements OpenAI Text-to-Speech (TTS) functionality to address the issue of robotic and unnatural system voice synthesis. The implementation provides users with high-quality AI-generated voices while maintaining full backward compatibility.

Key Features

OpenAI TTS Integration

  • Full support for OpenAI's TTS API (/v1/audio/speech)
  • Six voice options: alloy, echo, fable, onyx, nova, shimmer
  • Two quality models: tts-1 (standard) and tts-1-hd (high quality)
  • Adjustable speech speed from 0.25x to 4.0x

Enhanced User Experience

  • New TTS settings panel in extension configuration
  • Automatic fallback to system TTS when OpenAI TTS is unavailable
  • Loading states during API calls with proper error handling
  • "Read Selected Text" context menu option for any selected text on web pages

Technical Implementation

  • Created dedicated TTS service module (src/services/openai-tts.mjs)
  • Updated ReadButton component with intelligent TTS selection
  • Proper audio management with blob cleanup
  • Comprehensive error handling with graceful degradation

Usage

  1. Enable "OpenAI TTS" in extension settings
  2. Enter OpenAI API key
  3. Select preferred voice and model
  4. Use ReadButton on ChatGPT responses for AI voice synthesis
  5. Right-click selected text and choose "Read Selected Text"

The implementation automatically detects TTS availability and falls back to system speech synthesis when needed, ensuring all existing functionality continues to work seamlessly.

Internationalization

Added translations for English and Chinese (Simplified) to support the new TTS settings interface.

Fixes #787.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Aug 21 '25 18:08 Copilot