A Speech Emotion Recognition (SER) system built with React Native (frontend) and Django REST Framework (backend), with a machine-learning model trained in Google Colab. The application records audio on mobile, sends it to a Django API, and receives predicted emotions such as happy, sad, angry, calm, etc.
This README provides:
- Full project overview
- Architecture
- Folder structure
- Backend (Django) setup
- Frontend (React Native) setup
- Authentication workflow
- Upload flow
- Model training (placeholder, to be added)
- Common errors & debugging
Voice Emotion AI enables users to record their voice on mobile and get an emotion classification. It integrates:
- Records audio
- Uses Expo or bare RN (depending on your environment)
- Sends audio to Django using authenticated requests (access + refresh token)
- Handles token refresh for long-running sessions
- Provides JWT authentication
- Accepts audio uploads securely
- Runs inference using a trained SER ML model
- Returns predicted emotion + confidence score
- Reads dataset (RAVDESS)
- Extracts MFCC features
- Trains CNN or LSTM model
- Exports model as
.h5or.pt - Loaded by Django at runtime
voice-emotion-ai/
│
├── backend/
│ ├── manage.py
│ ├── requirements.txt
│ ├── backend/
│ │ ├── settings.py
│ │ ├── urls.py
│ │ └── wsgi.py
│ ├── emoapp/
│ │ ├── views.py
│ │ ├── models.py
│ │ ├── utils.py # ML model loading + inference
│ │ ├── urls.py
│ │ └── ml_models/
│ │ ├── emotional_recognition_model.h5 or model.pt
│ │ └── label_encoder.pkl
│ │ └── scaler.pkl
│ └── media/
│ └── audio_uploads/
│
├── frontend/
│ ├── README.md
│ ├── package.json
│ ├── app/
│ │ ├── api/
│ │ │ ├── axiosConfig.js
│ │ │ └── api.ts
│ │ ├── hooks/
│ │ │ └── useAuthRefresh.js
│ │ ├── tabs/
│ └── assets/
│
└── model-training/ # to be added
└── colab_notebook.ipynb
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
The system uses JWT with:
- Access Token (short-lived)
- Refresh Token (long-lived)
- User logs in → receives access + refresh
- Access token expires → upload requests start failing (
401 Unauthorized) - React Native should automatically call refresh endpoint
- Backend issues a new access token
- Upload retry succeeds
If refresh is not called → audio upload fails.
- Record audio using
expo-avorreact-native-audio-recorder-player - Convert audio →
FormData - Send
POST /recordings/upload/with header:
Authorization: Bearer <access_token>
- If
401→ call refresh token
- Receives audio
- Saves to
media/voice_recordings/ - Loads ML model
- Extracts MFCC features
- Runs prediction
- Returns:
{
"emotion": "happy",
"confidence": 0.92
}Include:
- Dataset download steps
- Preprocessing (MFCC extraction)
- Model architecture
- Training logs
- Export steps
Correct → CORS does not apply to React Native mobile apps. Only browsers.
Caused by expired access token. Fix: implement refresh.
Add this to settings.py:
LOGGING = {
"version": 1,
"handlers": {"console": {"class": "logging.StreamHandler"}},
"loggers": {
"django": {"handlers": ["console"], "level": "DEBUG"},
"emotion_app": {"handlers": ["console"], "level": "DEBUG"},
},
}
Use:
import { useColorScheme } from 'react-native';
const colorScheme = useColorScheme();
Install dependencies:
npm install
npx expo install expo-av
npm install axios
Run app:
npx expo start
POST /auth/login/POST /auth/register/
POST /recordings/upload/
Use Postman / Thunder Client to verify:
- Login
- Upload audio
- Verify response
MIT
Pull requests welcome. Open issues before major changes to discuss direction.