🎯 PyTTSLib
🔊 A powerful and easy-to-use Python Text-to-Speech library that supports multiple TTS engines.
✨ Features
- 🎙️ Multiple TTS engine support:
- 🖥️ pyttsx3 (offline, default) - Works without internet
- 🌐 Google TTS - High-quality online TTS
- 🎛️ Voice customization:
- 🏃♂️ Adjustable speech rate
- 📊 Volume control
- 👥 Multiple voice options
- 💾 Save audio to multiple formats (MP3, WAV)
- 🔄 Smart file management with auto-cleanup
- 🖥️ Cross-platform compatibility (Windows, Linux, macOS)
- 🛡️ Robust error handling
- 📝 Well-documented API
🚀 Installation
pip install pyttslib
📖 Quick Start
from pyttslib import TextToSpeech
# Create a TTS instance (default: pyttsx3 engine)
tts = TextToSpeech()
# Basic text-to-speech
tts.speak("Hello, world!")
# Use Google TTS instead
gtts = TextToSpeech(engine="google")
gtts.speak("Hello from Google Text-to-Speech!")
# Save speech to a file
tts.save_to_file("This will be saved as audio.", "output.mp3")
🎮 Advanced Usage
🎛️ Voice Configuration
# Configure pyttsx3 engine
tts = TextToSpeech(engine="pyttsx3", engine_config={
"rate": 150, # Words per minute
"volume": 0.8, # Volume level (0.0 to 1.0)
})
# Configure Google TTS
tts = TextToSpeech(engine="google", engine_config={
"lang": "en", # Language code
"tld": "com", # Top-level domain
"slow": False # Normal speed
})
🎭 Voice Selection
# List available voices
voices = tts.list_voices()
for voice in voices:
print(f"Voice: {voice['name']} (ID: {voice['id']})")
# Set a specific voice
tts.set_voice("en_female_1") # Voice ID from list_voices()
⚙️ Speech Properties
# Adjust speech rate (pyttsx3 only)
tts.set_rate(150) # Words per minute
# Adjust volume (pyttsx3 only)
tts.set_volume(0.8) # 80% volume
🌟 Examples
The package includes example scripts in the examples/ directory:
- 📝
basic_usage.py: Demonstrates fundamental features - 🔧
advanced_usage.py: Shows advanced functionality
Run the examples:
python examples/basic_usage.py
python examples/advanced_usage.py
🔍 Supported Audio Formats
- 🎵 MP3 (Google TTS)
- 🔊 WAV (pyttsx3)
- 🎼 OGG (platform-dependent)
- 🎹 AIFF (platform-dependent)
🛠️ Technical Details
File Management
- 📁 Temporary files are stored in a dedicated folder
- 🧹 Automatic cleanup after playback
- 💫 Robust retry mechanism for file operations
- 🔒 Safe file handling with proper resource cleanup
Error Handling
- ⚠️ Custom exception classes for better error management
- 🔄 Automatic retries for transient failures
- 📢 Clear error messages and logging
- 🛡️ Graceful fallbacks for playback methods
🤝 Contributing
Contributions are welcome! Here's how you can help:
- 🍴 Fork the repository
- 🌿 Create your feature branch (
git checkout -b feature/amazing-feature) - 💾 Commit your changes (
git commit -m 'Add amazing feature') - 📤 Push to the branch (
git push origin feature/amazing-feature) - 🎯 Open a Pull Request
📄 License
MIT License - feel free to use this in your projects!
🙏 Acknowledgments
- 🎤 pyttsx3 for offline TTS
- 🌐 gTTS for Google TTS support
- 🔊 playsound for cross-platform audio playback
📞 Support
- 📧 Report issues on GitHub
- 💭 Submit feature requests
- 🤝 Pull requests are welcome
Made with ❤️ for the Python community
Metadata
Release files for pyttslib 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyttslib-0.1.0.tar.gz | 15.5 kB | Without provenance | Details for pyttslib-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyttslib-0.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for pyttslib-0.1.0-py2.py3-none-any.whl |
Total release size: 26.6 kB
Release files / pyttslib-0.1.0.tar.gz
| Download URL | pyttslib-0.1.0.tar.gz |
|---|---|
| Size | 15.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06e38157ae214775fda544299381979ae9eed06dcf5f585920bbcff161c2ee82
|
|
BLAKE2b-256 checksum How to use checksums |
156d32228528a7dfa669e28cbdedaf2cab715f542c04199e101158884f0528b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Release files / pyttslib-0.1.0-py2.py3-none-any.whl
| Download URL | pyttslib-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a284016281913e801fcbd14638d0c6048c04dd0701ae3b8b342599615e4bb5c2
|
|
BLAKE2b-256 checksum How to use checksums |
e6b79b798644a781589bc87577d8a946810069cdc532a0c16f448552adcd45a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Security for pyttslib 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.