Skip to content

Latest commit

 

History

History
88 lines (74 loc) · 2.85 KB

Readme.md

File metadata and controls

88 lines (74 loc) · 2.85 KB

Python contextual chatbot with voice recognition.

Major packages used

  • Speech Recognition
  • PyTorch
  • Pyttsx
  • NLTK

Project requirements

  • Python 3.7-3.9 (Pytorch limitation)

Installation Process

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

Features

  • 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.

Customize

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.

Acknowledgements