Skip to content
Permalink
Browse files
Update speech_to_text
  • Loading branch information
spanosm committed Nov 28, 2018
1 parent 10ccd61 commit f32067aef08809ad34b0c602b3a3d18680930471
Showing 1 changed file with 27 additions and 1 deletion.
@@ -1 +1,27 @@
https://realpython.com/python-speech-recognition/#how-speech-recognition-works-an-overview
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)

0 comments on commit f32067a

Please sign in to comment.