- Speech Recognition
- PyTorch
- Pyttsx
- NLTK
Python 3.7-3.9
(Pytorch limitation)
First clone this git repository or download zip
git clone https://github.com/shz-code/chatbot-nltk.git
Create a new virtual environment(Use Conda/ Virtual Environment) Learn More.
*If virtual environment is not installed on your machine install it using below command.
pip install virtualenv
Activate virtualenv
virtualenv env
.\env\Scripts\activate
Run pip to install all the dependencies
pip install -r requirements.txt
Train your model based on intents.json
It will create data.pth
which is the model data.
py .\nlp_pipeline\train.py
If you get an error during the first run, you also need to install nltk.tokenize.punkt
:
Run this once in your terminal:
python
>>> import nltk
>>> nltk.download('punkt')
Finally start main.py
py main.py
- Users can chat or speak with the bot.
- The bot can generate answers based on pre-defined conditions or it will generate answer trained from intents.json data.
You can easily feed more data or customize the model by adding or modifying intents.json file.
For example
{
"intents": [
{
"tag": "new-tag",
"patterns": [
"all the question patterns related to that tag",
"question 1",
"question 2"
],
"responses": [
"all the response patterns related to that tag",
"response 1",
"response 2"
]
},
...
]
}
NB: You need to train your model again if you have modified the intents.json file. Run train.py
file to train your chatbot. If you see no changes happening than delete the old data.pth file and train again.
- Main Project idea Patrick Loeber
- Main article Contextual Chatbots with TenserFlow
- Supporting article Complete guide to build your ai chatbot with nlp in python