Skip to content

Python Contextual Chatbot with Voice Recognition.

Notifications You must be signed in to change notification settings

shz-code/chatbot-nltk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages