This project records audio from your microphone, transcribes it to text, and analyzes the sentiment of the transcribed text using a pre-trained sentiment analysis model from the Hugging Face Transformers library.
- Record audio for a specified duration.
- Transcribe recorded audio to text using Google Speech Recognition.
- Analyze sentiment of the transcribed text (positive/negative) using a sentiment analysis model.
- Python 3.9 or higher
pyaudio
for audio recordingspeech_recognition
for transcribing audiotransformers
for sentiment analysis
-
Clone the repository:
git clone https://github.com/superco01/nlp.git cd nlp
-
Create a virtual environment (optional but recommended):
conda create -n nlp-env python=3.9 conda activate nlp-env
-
Install the required packages:
pip install pyaudio speechrecognition transformers
-
Run the script:
python main.py
-
The script will record audio for 5 seconds (you can modify this in the code), transcribe it to text, and print the sentiment analysis result.
- record_audio(filename, duration): Records audio from the microphone and saves it to a specified file.
- transcribe_audio(filename): Uses the SpeechRecognition library to convert audio to text.
- main(): The main function that coordinates audio recording, transcription, and sentiment analysis.
Feel free to submit issues or pull requests if you'd like to contribute!
This project is licensed under the MIT License.