## there are any command line arguments or not. If there are, it will be a    ##
## server, otherwise a client. The client will read images from ~/testimages  ##
## and send them to the server. The server will receive and show images that  ##
## have been received over the socket.                                        ##
################################################################################
if __name__ == "__main__":
    from ticker import Ticker
    import glob
    import random
    import logging
    import loggingextra
    import hashlib
    import os

    logging.getLogger('Borg.Brain.Util').addHandler(
        loggingextra.ScreenOutput())
    logging.getLogger('Borg.Brain.Util').setLevel(logging.DEBUG)

    server = False
    if len(sys.argv) > 1:
        server = True

    name = "PictureServer" if server else "PictureClient"
    host = "localhost"
    port = "Pictures"

    if not server:
        # The client loads images to send
        path = os.path.join(os.environ['BORG'], "brain", "data", "models",
                            "RobotLab_1", "*.jpg")
        path = os.path.expanduser(path)
Ejemplo n.º 2
0
    Play an wave.wave_read object using alsaaudio
    """

    def _play_wave(self, wavestream):
        pcm = PCM(type=PCM_PLAYBACK, mode=PCM_NORMAL, card='default')
        pcm.setchannels(wavestream.getnchannels())
        pcm.setrate(wavestream.getframerate())
        pcm.setformat(PCM_FORMAT_S16_LE)
        pcm.write(wavestream.readframes(1000000))


"""
Example script
"""
t = MaryTTS()
if __name__ == "__main__":
    logging.getLogger('Borg.Brain').addHandler(loggingextra.ScreenOutput())
    logging.getLogger('Borg.Brain').setLevel(logging.DEBUG)
    import random

    while True:
        voices = t.get_voices()
        voice = voices[random.randint(0, len(voices) - 1)]
        t.set_voice(voice)
        print "Selected voice %s" % voice
        print "Please enter what you would like me to say"
        txt = raw_input()
        if "quit" == txt:
            break
        t.say(txt)