This application allows users to translate text or uploaded files (TXT, PDF, CSV, Excel) into multiple languages, convert the translated text to speech, and download the resulting audio. It leverages Google's Gemini API for translation and gTTS for speech synthesis.
- Translate free text or uploaded files (TXT, PDF, CSV, Excel)
- Convert translated text to speech (audio)
- Download the audio file
- Supports multiple languages
git clone Praveensjk/PythonProject
cd CapstoneProject
python -m venv .venv
.venv\Scripts\activate # On Windows
pip install -r requirements.txt
If requirements.txt is missing, install manually:
pip install streamlit gtts python-dotenv requests pandas PyPDF2 openpyxl
- Obtain a Gemini API key from Google (https://aistudio.google.com/app/apikey)
- Create a
.envfile in the project root:
GEMINI_API_KEY="your-gemini-api-key"
streamlit run main.py
- Enter text in the text area or upload a file (TXT, PDF, CSV, Excel)
- Select the target language
- Click the "Translate" button
- View the translated text, listen to the audio, and download the audio file
- Gemini API: Free tier may have usage limits. API response time may vary.
- gTTS: Limited voice/tone control. Only supports languages available in Google TTS.
- File Uploads: Large files or complex PDFs may not extract text perfectly.
- Security: Do not expose your API key publicly.
- Error Handling: The app provides basic error messages for failed translations or unsupported file types.
- Ensuring robust text extraction from various file formats (especially PDFs)
- Handling special characters and formatting for TTS
- Managing API errors and rate limits
- Keeping the code modular and maintainable
main.py: Streamlit UI and app logicconfig.py: Loads environment variablesservices/translation.py: Translation logicservices/tts.py: Text-to-speech logicservices/file_extractor.py: File reading and text extractionutils/text_cleaner.py: Text cleaning utilities
For more details, see the full documentation.