示例#1
0
def launch(window,numberColumn,keepon,*i):
    """ To launch the movements of a Keepon
    Arguments:
    - window : for keeponMove --> "quiz" or other
    - numberColumn = 2 (left) or 3 (right)
    4 or 5 (end question)
    - keepon: initialisation of the Keepon with serial (from the controller.py)
    - i: question number (useless if window != "quiz")
    """
    listeKeepon = d.robotData(window,numberColumn,"Keepon")
    listeKeeponInitialization = d.robotData("Position Initialisation",numberColumn,"Keepon")
    if window == "quiz":# i is a tuple, we have to transform it in int
        a = threading.Thread(None, keeponMove, None, (listeKeepon,listeKeeponInitialization,window,keepon,i[0]), {})
    else:
        a = threading.Thread(None, keeponMove, None, (listeKeepon,listeKeeponInitialization,window,keepon), {})
    return a
示例#2
0
def initialize(numberColumn, robotIP, port):
    """ To initialize the Nao"""
    #time.sleep(0.5)
    managerProxy = ALProxy("ALBehaviorManager", robotIP, port)
    listeNao = d.robotData("Position Initialisation", numberColumn, "Nao")
    a = threading.Thread(
        None, naoMove, None,
        ([], listeNao, "Position Initialisation", managerProxy), {})
    return a
示例#3
0
def lengthTest(numberColumn):
    voice = d.robotData("End window", numberColumn, "Nao Voices")
    length = 0.0
    for i in range(len(voice)):
        if type(voice[i]) != long and type(voice[i]) != float:
            a = 'Voices/' + voice[i]
            sound = pyglet.resource.media(a)
            length = sound.duration
            print(a + " :" + str(length))
    print('\n')
示例#4
0
def lengthQuizTest(numberColumn):
    voice = d.robotData("quiz", numberColumn, "Nao Voices")
    length = 0.0
    for i in range(len(voice)):
        for j in range(len(voice[i][j])):
            if type(voice[i][j]) != long and type(voice[i][j]) != float:
                a = 'Voices/' + voice[i]
                sound = pyglet.resource.media(a)
                length = sound.duration
                print("Question " + str(i + 1) + " :" + str(length))
    print('\n')
示例#5
0
def otherVoicesTest(numberColumn, window):
    voice = d.robotData(window, numberColumn, "Nao Voices")
    length = 0.0
    for j in range(len(voice)):
        if type(voice[j]) == long or type(voice[j]) == float:
            time.sleep(voice[j] + length)
        else:
            player = pyglet.media.Player()
            a = 'Voices/' + voice[j]
            sound = pyglet.resource.media(a)
            length = sound.duration
            player.queue(sound)
            player.play()
示例#6
0
def launch(window, numberColumn, robotIP, port, *i):
    """ To launch the movements of a Nao
    Arguments:
    - window : for keeponMovement --> "quiz" or other
    - numberColumn : 2 (left) or 3 (right)
    4 or 5 (end question)
    - robotIP and port: initialisation of the Nao
    - i: question number (might be useless following the window)
    """
    managerProxy = ALProxy("ALBehaviorManager", robotIP, port)
    listeNao = d.robotData(window, numberColumn, "Nao")
    listeNaoInitialization = d.robotData("Position Initialisation",
                                         numberColumn, "Nao")
    if window == "quiz":  # i is a tuple, we have to transform it in int
        a = threading.Thread(
            None, naoMove, None,
            (listeNao, listeNaoInitialization, window, managerProxy, i[0]), {})
    else:
        a = threading.Thread(
            None, naoMove, None,
            (listeNao, listeNaoInitialization, window, managerProxy), {})
    return a
示例#7
0
def getLength(numberColumn,i):
    """ To get the length of the audio files for the quiz
    Arguments:
    - numberColumn = 2 (main voices) 3 or 4 (voices for end question)
    - i --> number of the question
    """
    voice = d.robotData("quiz",numberColumn,"Keepon Voices")
    length = 0.0
    for j in range(len(voice[i])):
        if type(voice[i][j]) == long or type(voice[i][j]) == float:
            length = length + voice[i][j]
        else:
            a = 'Voices/' + voice[i][j]
            sound = pyglet.resource.media(a)
            length = length + sound.duration# to get length in second of the audio file
    return length
示例#8
0
def otherVoices(window):
    """ To play the audio files for the welcome and end window
    Arguments:
    - window: Welcome window or End window
    """
    voice = d.robotData(window,2,"Keepon Voices")
    length = 0.0
    for j in range(len(voice)):
        if type(voice[j]) == long or type(voice[j]) == float:
            time.sleep(voice[j]+length)
        else:
            player = pyglet.media.Player()
            a = 'Voices/' + voice[j]
            sound = pyglet.resource.media(a)
            length = sound.duration
            player.queue(sound)
            player.play()
示例#9
0
def otherVoices(window, numberColumn, robotIP, port):
    """ To play the audio files for the welcome and end window
    Arguments:
    - window: Welcome window or End window
    - numberColumn: 2 (left) or 3 (right) (main voices)
    - robotIP
    - port
    """
    aup = ALProxy("ALAudioPlayer", robotIP, port)
    voice = d.robotData(window, numberColumn, "Nao Voices")
    for j in range(len(voice)):
        if type(voice[j]) == long or type(voice[j]) == float:
            time.sleep(voice[j])
        else:
            a = str("/home/nao/voices/" + voice[j])  # important!!
            fileId = aup.loadFile(a)  # take only str (and not unicode!)
            aup.play(fileId)
示例#10
0
def quizVoices(numberColumn,i):
    """ To play the audio files for the quiz
    Arguments:
    - numberColumn = 2 (main voices) 3 or 4 (voices for end question)
    - i --> number of the question
    """
    voice = d.robotData("quiz",numberColumn,"Keepon Voices")
    length = 0.0
    for j in range(len(voice[i])):
        if type(voice[i][j]) == long or type(voice[i][j]) == float:
            time.sleep(voice[i][j] + length)
        else:
            player = pyglet.media.Player()
            a = 'Voices/' + voice[i][j]
            sound = pyglet.resource.media(a)
            length = sound.duration
            player.queue(sound)
            player.play()
示例#11
0
def quizVoices(numberColumn, robotIP, port, i):
    """ To play the audio files for the quiz
    Arguments:
    - numberColumn = 2 (left) or 3 (right) (main voices)
    4 or 5 (voices for end question)
    - robotIP
    - port
    - i: number of the question
    """
    aup = ALProxy("ALAudioPlayer", robotIP, port)
    voice = d.robotData("quiz", numberColumn, "Nao Voices")
    for j in range(len(voice[i])):
        if type(voice[i][j]) == long or type(voice[i][j]) == float:
            time.sleep(voice[i][j])
        else:
            a = str("/home/nao/voices/" + voice[i][j])  # important!!
            fileId = aup.loadFile(a)  # take only str (and not unicode!)
            aup.play(fileId)
示例#12
0
def getLengthTest(numberColumn, i):
    """ To get the length of the audio files for the quiz window
    Arguments:
    - numberColumn: 2 (left) or 3 (right) (main voices)
    - robotIP
    - port
    - i: question number
    """
    voice = d.robotData("quiz", numberColumn,
                        "Nao Voices")  # data.py,numberColumn = 2 always
    length = 0.0
    for j in range(len(voice[i])):
        if type(voice[i][j]) == long or type(voice[i][j]) == float:
            length = length + voice[i][j]
        else:
            a = 'Voices/' + voice[i][j]
            sound = pyglet.resource.media(a)
            length = length + sound.duration
    return length
示例#13
0
def getLengthBis(numberColumn, i):
    """ To get the length of the audio files for the quiz
    Arguments:
    - numberColumn = 2 (main voices) 3 or 4 (voices for end question)
    - i --> number of the question
    WARNING: this function has been written to replace the function getLength
    and then trying to solve the problems with the audio files.
    It improves the system but didn't resolve completely the audio files issues
    """
    voice = d.robotData("quiz", numberColumn, "Nao Voices")
    length = 0.0
    for j in range(len(voice[i])):
        if type(voice[i][j]) == long or type(voice[i][j]) == float:
            length = length + voice[i][j]
        else:
            a = 'Voices/' + voice[i][j]
            sound = pyglet.resource.media(a)
            length = length + sound.duration  # to get length in second of the audio file
    return length
示例#14
0
def getLength(numberColumn, robotIP, port, i):
    """ To get the length of the audio files for the quiz window
    Arguments:
    - numberColumn: 2 (left) or 3 (right) (main voices)
    - robotIP
    - port
    - i: question number
    WARNING: this function is not used yet because it seems causing troubles
    for the system (see next function: getLengthBis)
    """
    aup = ALProxy("ALAudioPlayer", robotIP, port)
    voice = d.robotData("quiz", numberColumn,
                        "Nao Voices")  # data.py,numberColumn = 2 always
    length = 0.0
    for j in range(len(voice[i])):
        if type(voice[i][j]) == long or type(voice[i][j]) == float:
            length = length + voice[i][j]
        else:
            a = str("/home/nao/voices/" + voice[i][j])  # important!!
            fileId = aup.loadFile(a)  # take only str (and not unicode!)
            time.sleep(
                0.1)  # to let the program load the file. If not, length = 0
            length = length + aup.getFileLength(fileId)
    return length + 1
示例#15
0
def initialize(numberColumn,keepon):
    listeKeepon = d.robotData("Position Initialisation",numberColumn,"Keepon")
    a = threading.Thread(None, keeponMove, None, (listeKeepon,"Position Initialisation",keepon), {})
    return a