0% found this document useful (0 votes)
23 views1 page

#Bot - Train (Data) : From Import From Import Import

This document contains code to train a chatbot using training data from files located in a specified directory, interact with the chatbot by getting its responses to user input, and recognize speech with Google Speech Recognition by listening from a microphone.

Uploaded by

alok haryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

#Bot - Train (Data) : From Import From Import Import

This document contains code to train a chatbot using training data from files located in a specified directory, interact with the chatbot by getting its responses to user input, and recognize speech with Google Speech Recognition by listening from a microphone.

Uploaded by

alok haryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

from chatterbot import ChatBot

from chatterbot.trainers import ListTrainer


import os

bot = ChatBot('bot')
bot.set_trainer(ListTrainer)

for files in os.listdir('C:/Users/Alok Haryan/Downloads/Tech Crptors Machine


learning/Prequisite/chatterbot-corpus-master/chatterbot_corpus/data/english'):
data = open ('C:/Users/Alok Haryan/Downloads/Tech Crptors Machine learning/Prequisite/chatterbot-
corpus-master/chatterbot_corpus/data/english/'
+ files, 'r').readlines()
#bot.train(data)

while True:
message =input("You: ")
if message.strip() !='Bye' :
reply = bot.get_response(message)
print("Chatbot: ", reply)
if message.strip() == 'bye' :
print("Chatbot: Bye")
break

import speech_recognition as sr

r = sr.Recognizer()
with sr.Microphone() as source:
print('say atharav')
audio = r.listen(source)
print(audio)
try:
print('google thinks you said:\n'
+ r.recognize_google(audio))
except:
print('there is something error in recognition')

You might also like