示例#1
0
def LoopButton():
    time.sleep(0.05)  # delay
    while not loop_button_t.stopped():
        if Hardware.Analog.read_channel(0) > 1000:
            Go_Crazy()
            Sound.wait_for_sound()
        loop_button_t.sleep(0.02)
示例#2
0
def Go_Crazy(text='', twitter=False, facebook=False):
    print_info('Do something!')

    global prev_emotion_int
    global emotion_int
    global prev_sound_int
    global sound_int

    while sound_int == prev_sound_int:
        sound_int = randint(0, len(sounds) - 1)

    while emotion_int == prev_emotion_int:
        emotion_int = randint(0, len(emotions_phis) - 1)

    prev_sound_int = sound_int
    prev_emotion_int = emotion_int

    if len(text) > 1:
        Sound.say_tts(text)
    else:
        Sound.play_file(sounds[sound_int])
    Expression.set_emotion_r_phi(1.0, emotions_phis[emotion_int], True, 0.5)

    Hardware.Serial.send('anim\n')

    if twitter:
        Hardware.Serial.send('set\nset 000000000000000000247e24247e24\n')

    if facebook:
        Hardware.Serial.send('set\nset 00000000000000000818185f5f5f5e5e\n')

    loop_t.sleep(2)

    print_info('Done doing something!')
示例#3
0
def playTweetInLanguage(text, lang):
    print_info("play tweet in language")
    if not os.path.exists("/tmp/OpsoroTTS/"):
        os.makedirs("/tmp/OpsoroTTS/")

    full_path = os.path.join(get_path("/tmp/OpsoroTTS/"), "Tweet.wav")
    print_info(full_path)

    TTS.create_espeak(text, full_path, lang, "f", "5", "150")
    Sound._play(full_path)
示例#4
0
def playTweetInLanguage(tweepyObj):
    print_info("play tweet in language")
    if not os.path.exists("/tmp/OpsoroTTS/"):
        os.makedirs("/tmp/OpsoroTTS/")

    full_path = os.path.join(get_path("/tmp/OpsoroTTS/"), "Tweet.wav")
    print_info(full_path)

    if (tweepyObj['text']['lang'] == 'und'):
        return

    TTS.create_espeak(tweepyObj['text']['filtered'], full_path,
                      tweepyObj['text']['lang'], "f", "5", "150")
    Sound._play(full_path)
示例#5
0
    def stop_streamreader(self):
        """
		Stop the streamreader and stops the sound.
        stopLoop and hasRecievedTweet is set to true to interrupt the StoppableThread

        """
        global myStream
        global hasRecievedTweet
        global stopLoop
        stopLoop = True
        myStream.disconnect()
        hasRecievedTweet = True
        Sound.stop_sound()
        print_info("stop twitter")
示例#6
0
def robot_sound():
    soundfile = request.args.get('s', type=str, default=None)

    if Sound.play_file(soundfile):
        return json.dumps({'success': True})

    return json.dumps({'success': False, 'message': 'Unknown file.'})
示例#7
0
    def playTweetInLanguage(self, tweet):
        """
        plays the tweet in a language, should not be called directly.

        :param string tweet:    list that has been processed in processJson.
        """
        if not os.path.exists("/tmp/OpsoroTTS/"):
            os.makedirs("/tmp/OpsoroTTS/")

        full_path = os.path.join(
            get_path("/tmp/OpsoroTTS/"), "Tweet.wav")

        if os.path.isfile(full_path):
            os.remove(full_path)

        TTS.create_espeak(tweet['text']['filtered'], full_path, tweet['text']['lang'], "f", "5", "150")

        Sound.play_file(full_path)
示例#8
0
def asyncReadTweet():
    time.sleep(0.05)
    global loop_PlayTweet
    global tweetArrayToPlay
    global lang
    global autolooping
    global playing
    while not loop_PlayTweet.stopped():
        for item in tweetArrayToPlay:
            if item[0] == 'txt':
                playTweetInLanguage(filterTweet(item[1]), lang)
                Sound.wait_for_sound()
            else:
                Expression.set_emotion_name(item[1], -1)
        loop_PlayTweet.stop()
        print_info(autolooping)
        if autolooping == 1:
            send_action("autoLoopTweepyNext")
        playing = False
def robot_sound():
    soundfile = request.args.get('s', type=str, default=None)

    if not is_safe_path(soundfile):
        return json.dumps({'success': False, 'message': 'Unknown file.'})

    soundfiles = []
    filenames = []

    filenames = glob.glob(get_abs_path(docs_data_path + 'sounds/*.wav'))

    for filename in filenames:
        soundfiles.append(os.path.split(filename)[1])

    if soundfile in soundfiles:
        Sound.play_file(soundfile)

        return json.dumps({'success': True})
    else:
        return json.dumps({'success': False, 'message': 'Unknown file.'})
def robot_stop():
    Sound.stop_sound()
    return json.dumps({'success': True})
def robot_tts():
    text = request.args.get('t', None)
    if is_safe_path(text):
        Sound.say_tts(text)

    return json.dumps({'success': True})
示例#12
0
def SocialscriptRun():
    Sound.wait_for_sound()
    send_stopped()