« first day (1362 days earlier)      last day (2016 days later) » 

5:39 PM
from commands1 import commander
from pygame.mixer import *
from googletrans import Translator
import speech_recognition as sr
# speech recognizer
r=sr.Recognizer()
pre_init()
init()
running=True
translator = Translator()
cmd=commander()
music.load('D:\Programming\python\coins.mp3')
#,'D:\Programming\python\end.mp3'])

def initSpeech():
print("Listening...")
with sr.Microphone() as source:
print("Please wait calibrating microphone...")
r.adjust_for_ambient_noise(source, duration=0.5)
print("Say Something")
So I have to make speech_recognition library listen to me twice in a single loop. To do so, executing specific functions twice to listen when its name is called and another time to listen to the command, is making my chatbot slow
because if I use speech_recognition library functions once in a single loop, its faster. That means it's always ready for commands and doesn't wait for its name called. For that I am sending another coding
from commands1 import commander
from pygame.mixer import *
from googletrans import Translator
import speech_recognition as sr
# speech recognizer
r=sr.Recognizer()
pre_init()
init()
running=True
translator = Translator()
cmd=commander()
def initSpeech():
print("Listening...")
music.load('D:\Programming\python\coins.mp3')

with sr.Microphone() as source:
print("Please wait calibrating microphone...")
r.adjust_for_ambient_noise(source, duration=1)
music.play()
print("Say Something")
audio=r.listen(source)
This is faster :-(
 
5 messages moved from Python
 

« first day (1362 days earlier)      last day (2016 days later) »