Ejemplo n.º 1
0
def main():
    try:
        if sys.argv[1] == '--text' or sys.argv[1] == '-t':
            text_mode = True
            speech_text = raw_input("Write something: ").lower().replace("'", "")
    except IndexError:
        text_mode = False
        r = sr.Recognizer()
        with sr.Microphone() as source:
            print("Say something!")
            audio = r.listen(source)

        try:
            speech_text = r.recognize_google(audio).lower().replace("'", "")
            print("Melissa thinks you said '" + speech_text + "'")
        except sr.UnknownValueError:
            print("Melissa could not understand audio")
        except sr.RequestError as e:
            print("Could not request results from Google Speech Recognition service; {0}".format(e))

    play_music.mp3gen(music_path)
    brain(name, speech_text, music_path, city_name, city_code, proxy_username, proxy_password)

    if text_mode:
        main()
    else:
        passiveListen()
Ejemplo n.º 2
0
def main():
    try:
        if sys.argv[1] == '--text' or sys.argv[1] == '-t':
            text_mode = True
            speech_text = raw_input("Write something: ").lower().replace(
                "'", "")
    except IndexError:
        text_mode = False
        r = sr.Recognizer()
        with sr.Microphone() as source:
            print("Say something!")
            audio = r.listen(source)

        try:
            speech_text = r.recognize_google(audio).lower().replace("'", "")
            print("Melissa thinks you said '" + speech_text + "'")
        except sr.UnknownValueError:
            print("Melissa could not understand audio")
        except sr.RequestError as e:
            print(
                "Could not request results from Google Speech Recognition service; {0}"
                .format(e))

    play_music.mp3gen(music_path)
    imgur_handler.img_list_gen(images_path)

    brain(name, speech_text, music_path, city_name, city_code, proxy_username,
          proxy_password, consumer_key, consumer_secret, access_token,
          access_token_secret, client_id, client_secret, images_path)

    if text_mode:
        main()
    else:
        passiveListen()
Ejemplo n.º 3
0
def main(voice_file):
    r = sr.Recognizer()
    with sr.WavFile(voice_file) as source:
        audio = r.record(source)

    try:
        speech_text = r.recognize_google(audio).lower().replace("'", "")
        print("Melissa thinks you said '" + speech_text + "'")
    except sr.UnknownValueError:
        print("Melissa could not understand audio")
    except sr.RequestError as e:
        print("Could not request results from Google Speech Recognition service; {0}".format(e))

    play_music.mp3gen(music_path)
    brain(name, speech_text, music_path, city_name, city_code, proxy_username, proxy_password)
Ejemplo n.º 4
0
def main(voice_file):
    r = sr.Recognizer()
    with sr.WavFile(voice_file) as source:
        audio = r.record(source)

    try:
        speech_text = r.recognize_google(audio).lower().replace("'", "")
        print("Melissa thinks you said '" + speech_text + "'")
    except sr.UnknownValueError:
        print("Melissa could not understand audio")
    except sr.RequestError as e:
        print(
            "Could not request results from Google Speech Recognition service; {0}"
            .format(e))

    play_music.mp3gen(music_path)
    brain(name, speech_text, music_path, city_name, city_code, proxy_username,
          proxy_password)
Ejemplo n.º 5
0
profile = open('profile.yaml')
profile_data = yaml.safe_load(profile)
profile.close()

# Functioning Variables
name = profile_data['name']
city_name = profile_data['city_name']
city_zip = str(profile_data['city_zip'])
music_path = profile_data['music_path']
access_token = profile_data['twitter']['access_token']
access_token_secret = profile_data['twitter']['access_token_secret']
consumer_key = profile_data['twitter']['consumer_key']
consumer_secret = profile_data['twitter']['consumer_secret']
amigo_host_port = profile_data['amigo']['host_port']
play_music.mp3gen(music_path)



tts('Welcome ' + name + ', systems are now ready to run. How can I help you?')

def main():
    r = sr.Recognizer()
    while True:
        # obtain audio from the microphone
        with sr.Microphone() as source:
            print("Say something!")
            audio = None
            speech_text = None
            while audio is None:
                audio = r.listen(source)