I am running the following code in Python 2.7 with pyAudio installed.
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:             
        I guess the problem is with the duration. If you set some duration to the speech recognition engine the problem will be resolved. Try the following code:
import speech_recognition as sr
r = sr.Recognizer()                                                                                   
with sr.Microphone() as source:                                                                      
    speak(sen)
    print("listening...")
    audio = r.record(source,duration=3)
    try:
        str=r.recognize_google(audio)
        print(str)
    except:
        print("some error occurred!")