Skip to content

pramodgslab/sentiment_analysis_api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment Analysis Flask App

This Flask application performs:

  • Text sentiment analysis using the CardiffNLP Twitter RoBERTa model.
  • Audio sentiment analysis by transcribing uploaded audio and analyzing the text sentiment.
  • Tone analysis of customer feedback.
  • Text-to-speech generation using ElevenLabs API.

Setup

  1. Clone the repository and navigate to the project directory.

  2. Create and activate a Python virtual environment:

python3 -m venv venv
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Make sure ffmpeg is installed on your system:
ffmpeg -version

If not installed, install it via your package manager, e.g.,

sudo apt install ffmpeg

Usage

Run the Flask app:

python app.py

API Endpoints

  • POST /analyze/text - Sentiment analysis for raw text.
  • POST /analyze/audio - Sentiment analysis for audio files.
  • POST /generate/audio - Generate speech audio from text using ElevenLabs API.

Important Notes

  • For audio files, the app converts audio to WAV format before transcription.
  • When using ElevenLabs text-to-speech output, you may need to convert the audio sample rate and channels for compatibility, e.g.:
ffmpeg -i elevenlabs_output.wav -ar 16000 -ac 1 -c:a pcm_s16le elevenlabs_output1.wav

This converts the audio to 16 kHz, mono channel, and PCM signed 16-bit little-endian format, often required for ASR or other audio processing tools.


CORS

CORS is enabled in the app for local Swagger UI and cross-origin requests.


Configuration

Set your ElevenLabs API key in the app (ELEVENLABS_API_KEY).

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published