Probelm with Poppy sound

Hi everyone,
I am using poppy-torso for my thesis, and I have a problem with poppy simulator (CoppeliaSim ) when I try to make him speak.
I program poppy with python, with pypot library. In my code, I program poppy to be a personal trainer, so he can demonstrate exercise with his upper body. The code works very well, but when I try to use voice, something in the robot’s movement isn’t working as before.
I have no idea why; someone have any idea?

Hello,

Can you provide a short piece of code formatted as a single Python script (NOT your whole code) that illustrates both the sound generation and the simulated motion generation, and that causes the issue?

hey, of course!
The code works in parallel programming in Python:
The TTS code – Audio:

def run(self):
    while (not s.finish_workout):
        if (s.str_to_say!=""):
            self.say_no_wait(s.str_to_say)
            s.str_to_say = ""
    print ("tts done - (tts class)")
def say_no_wait(self, str_to_say):
    '''
    str_to_say = the name of the file
    This function make the robot say whatever there is in the file - play the audio (paralelly)
    :return: audio
    '''
    mixer.init()
    mixer.music.load(s.audio_path+str_to_say+'.wav')
    mixer.music.play()
    print ("say_no_wait function - (tts class) "+str_to_say)

Poopy class - example of an exercise:

self.poppy = PoppyTorso(simulator='vrep')  # for simulator

def run_exercise(self, exercise, exercise_name):
    print("Poppy class - run_exercise function "+str(exercise.number))
    s.success_exercise = False
    s.str_to_say = exercise_name #for the robot to speak
    time.sleep(4.5)
    s.req_exercise = exercise.__name__
    exercise() #the function of the current exercise.

@func_attributes(number='1L' ,instructions="raise left arm horizontally")
def raise_left_arm_horiz(self):
    for i in range(s.rep):
        right_hand_up = [self.poppy.r_shoulder_x.goto_position(-90, 1.7, wait=False),
                         self.poppy.r_elbow_y.goto_position(90, 1.7, wait=False)] #1.7
        time.sleep(2)
        right_hand_down = [self.poppy.r_shoulder_x.goto_position(0, 1.7, wait=False),
                           self.poppy.r_elbow_y.goto_position(90, 1.7, wait=False)]
        time.sleep(2)
        if (s.success_exercise):
            break

I hope it will help u understand my problem.
Thank u!!

Does “parallel programming” mean multihreading or multiprocessing?
Could it be due to the fact that your CPU is overloaded? What is the CPU load?

multihreading.
ya i thought about it. how can I check if my CPU is overloaded?

thanks,
Naama

Simply use your system monitor, or htop for Linux.
I would recommend the use of multiprocessing, at least to test if your issue is due to multiprocessing.

hey,
I tried to run the simulation on two different computers, but it still happens.
Also, it doesn’t happen in the robot, so maybe the problem is with the simulator –coppeliaSim.
Does someone use this simulator with audio and the robot movements works fine?

Naama

Still need help please!

Can you use multiprocessing instead of multithreading? The first works pretty much the same way than the second:

import time, multiprocessing
def second_process():
    for i in range(10):
        print("Hello from the second process!")
        time.sleep(1)

new_process = multiprocessing.Process(target=second_process)
new_process.start()

for i in range(10):
    print("Hello from the first process!")
    time.sleep(1)

new_process.join()