Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Python_Telegram_Chat_bot/speech_to_text
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (18 sloc)
857 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from chatterbot import ChatBot | |
import speech_recognition as sr | |
from chatterbot.trainers import ListTrainer | |
r = sr.Recognizer() | |
bot = ChatBot('Darwin' , input_adapter="chatterbot.input.VariableInputTypeAdapter") | |
conv = open('chat_text.txt' , 'r').readlines() | |
bot.set_trainer(ListTrainer) | |
bot.train(conv) | |
while True: ##Audio input , conversion to text , inputs text to the chatbot | |
with sr.Microphone() as source: | |
print("tell me something ") | |
audio = r.listen(source) | |
try: | |
text = r.recognize_google(audio) | |
print(text) | |
request = text ## error , request won't accept the variable text as input ( text stores the audio input converted into text) | |
response = bot.get_response(request) | |
print('Bot:', response) |