This is a Flask-based web application designed to help Moroccan primary school students practice French reading and pronunciation. The app allows users to retrieve random texts based on levels and difficulties, record their readings, and receive detailed pedagogical feedback using AI-driven audio analysis and natural language processing. It is tailored to the Moroccan educational context, ensuring privacy with local processing and providing culturally relevant feedback.
- Target Audience: Moroccan primary students (e.g., level 6).
- Language: French.
- Key Features: Text retrieval, audio upload, pronunciation scoring, text accuracy evaluation, and personalized feedback.
- Python 3.8 or higher.
- MongoDB (local or cloud instance).
- Internet connection (for API calls and initial model downloads).
-
Clone the Repository:
git clone https://github.com/NextGenEduMA/LectureEval-FR-ver.git cd LectureEval-FR-ver -
Create a Virtual Environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install Dependencies:
pip install -r requirements.txt
Note: Create a
requirements.txtfile with the following content:flask pymongo librosa pydub soundfile gtts transformers torch fastdtw jiwer python-dotenv requests -
Configure Environment Variables:
- Create a
.envfile in the root directory:HF_TOKEN=your_huggingface_token GEMINI_API_KEY=your_google_api_key MONGO_URI=mongodb://localhost:27017 - Replace placeholders with your actual API keys and MongoDB URI.
- Create a
-
Set Up MongoDB:
- Install MongoDB locally or use a cloud service (e.g., MongoDB Atlas).
- Create a database
language_learningand a collectiontextswith sample data (e.g., French texts withid,content,language,level,difficulty).
-
Initialize File Structure:
- Create directories:
Uploads/,static/audio/,reference_audio/, andtemplates/. - Add an
index.htmlfile intemplates/for the web interface.
- Create directories:
-
Run the Application:
python app.py
- Access the app at
http://localhost:5000.
- Access the app at
- Get a Random Text:
- Visit
/get_random_text?language=fr&level=6&difficulty=mediumto retrieve a text.
- Visit
- Generate Reference Audio:
- Use
/text-to-speechwith a JSON payload (e.g.,{"text": "Les élèves préparent un spectacle.", "language": "fr"}) to get an audio URL.
- Use
- Evaluate Pronunciation:
- Upload an audio file via
/evaluatewith form data (reference_text,text_id,language,level,difficulty). - Receive a JSON response with scores, transcription, and feedback.
- Upload an audio file via
- View Feedback:
- The web interface displays pronunciation accuracy, text accuracy, reading speed, and pedagogical tips.
- Framework: Flask (Python web framework).
- Database: MongoDB (NoSQL for text storage).
- Audio Processing: Librosa (feature extraction), Pydub (audio conversion), Soundfile (duration), gTTS (text-to-speech).
- AI and Analysis:
- Transformers (Hugging Face) for Whisper (speech-to-text) and DistilGPT2 (fallback feedback).
- FastDTW (pronunciation scoring).
- Jiwer (text accuracy metrics).
- Google Generative Language API (Gemini-1.5-Flash for feedback).
- Utilities: Dotenv (environment variables), Threading (parallel processing), OS/Tempfile/UUID (file management).
- RAG: Custom RAGRetriever for context-specific pedagogical tips.
Description: The architecture includes a Flask server as the central hub, interacting with a MongoDB database for text storage, an audio processing pipeline (Librosa, Pydub, Soundfile, gTTS), and an AI pipeline (Whisper, Jiwer, FastDTW, Gemini, DistilGPT2). The RAGRetriever enhances feedback, and a file system manages audio files. Users access the system via a web interface.
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch. - Make your changes and commit:
git commit -m "Add new feature". - Push to the branch:
git push origin feature-branch. - Submit a pull request.
