Skip to content

Chatbot with Intent Pattern Recognition & Speech Recognition [WIP]

Notifications You must be signed in to change notification settings

LuluW8071/Virtual-Assistant

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

77 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Assistant

Features

  • Speech Recognition: Utilizes the Vosk model for accurate speech recognition, enabling seamless interaction through voice commands.
  • Intent Classification: Employs a three-layer linear model with ReLU activation functions to classify user intents effectively.
  • Basic Task Automation: Capable of performing various basic tasks, such as creating, renaming, and deleting folders, searching the web, managing device controls, and more.
  • Expandability: Can be easily expanded to accommodate additional functionalities based on specific user needs.

Usage

To use the Virtual Assistant:

  • Download Speech Recongition Model: Extract the compressed .rar file inside model named directory.

    Click here

  • Install Dependencies:

    pip install -r requirements.txt
  • Run train.py for Intent Classification:

    py .\neuralnet\train.py -e <EPOCHS> -b <BATCH_SIZE> -p <PLOT:1>  
    Argument Short Option Type Default Help
    --batch_size -b int 8 Batch size for training
    --epochs -e int 250 Number of epochs for training
    --plot -p int 0 Whether to plot the loss curve (1 for yes, 0 for no)

    The intent.pth will be saved under model directory after executing train.py.

  • Set API Keys:

    Create a .env file in the main directory of the project. Inside the .env file, define the variable for your API key

    Below is a list of websites and APIs used in this project. Click on the links to access their documentation and obtain the necessary information.

    • Open Weather Map

      Make sure to review the documentation for each API to understand their usage and any specific requirements, such as obtaining API keys or authentication tokens.

    WEATHER_API_KEY = "{{secret.YOUR_API_KEY}}"
  • Run Script:

    py chat.py
  • Interaction:

    You: hello
    ByteBot: Hi there, how can I assist you today?
    You: tell me a joke
    ByteBot: A perfectionist walked into a bar...apparently, the bar wasn't set high enough
    You:  
    
  • Customization:

    If you want to customize the intent according to your needs, add the tags, patterns and responses inside intents.json in following format and re-run train.py while adding functionality features in chat.py. The intent.json should follow this base format:

    {
        "intents": [
            {
                "tag": "greeting",
                "patterns": [
                    "Hi there",
                    "Hello",
                    "yo"
                ],
                "responses": [
                    "Hello",
                    "Good to see you again",
                    "Hi there, how can I help?"
                ],
            }
        ]
    }

Speech Recognition Model

If the speech recognition model shows errors, run this script on the same directory path

from engine import initialize_model, speech_recognize
# Transcript
transcript = ''

if __name__ == "__main__":
    recognizer, mic, stream = initialize_model()

    while True:
        data=stream.read(4096)
        if recognizer.AcceptWaveform(data):
            result = recognizer.Result()[14:-3]
            transcript += result + ' '
            print(transcript)

Contributors

Limitations

The current version of the Virtual Assistant may have limitations in complex tasks or specialized domains. You can add more functions or integrate Language Models like Llama2, MistralAI, BERT.


Feel free to customize and extend the Virtual Assistant to suit your specific needs and requirements. Contributions and feedback are welcome!

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%