Fixed RTL Support: The script already has good support for the Arabic language with RTL (Right-to-Left) text direction in the UI elements.
Maintained Model Update: Kept the updated model change from "tts-1" to "gpt-4o-mini-tts" for higher quality speech synthesis.
Preserved Error Handling: The script includes comprehensive error handling for API issues, authentication problems, and audio processing errors.
How to Use:
Install the Tampermonkey browser extension if you don't have it already
Create a new script in Tampermonkey
Copy and paste the code above
Replace "YOUR_API_KEY_HERE if you want" with your actual OpenAI API key
Save the script
Visit any webpage, select text, and click the green button to hear it read aloud
The script provides a floating button that reads selected text using OpenAI's TTS service, with controls for voice selection, volume, and playback speed.