diff --git a/Jarvis.py b/Jarvis.py index 910951e7154fe65b0e206d56b1f11fe843be49a8..fb3e81e2c2381d2babd7f0845506c045c35576f9 100755 --- a/Jarvis.py +++ b/Jarvis.py @@ -393,45 +393,34 @@ def tests(entre): get_endevent() ''' if "play" in entre or "joue de la musique" in entre or "met de la musique" in entre: - # os.system("rhythmbox-client --play --shuffle") - # process = Popen(["rhythmbox-client", "--print-playing"], stdout=PIPE, stderr=PIPE) - # stdout, stderr = process.communicate() - indice_sound = random.randint(0, len(playlist_sound) - 1) - sound = playlist_sound[indice_sound] - pygame.mixer.Channel(1).play(sound) - parle("j'ai lancé " + playlist_text[indice_sound].split("/")[-1].replace(".mp3", ""), False) + process = Popen(["sound_player/player-client.py", "play"], stdout=PIPE, stderr=PIPE) + stdout, stderr = process.communicate() + parle("j'ai lancé " + stdout.split(":").strip(), False) if "pause" in entre: - # os.system("rhythmbox-client --pause") - pygame.mixer.Channel(1).pause() - parle("pause") + process = Popen(["sound_player/player-client.py", "pause"], stdout=PIPE, stderr=PIPE) + stdout, stderr = process.communicate() if "musique suivante" in entre: - # os.system("rhythmbox-client --next") - indice_sound = (indice_sound + 1) % len(playlist_sound) - sound = playlist_sound[indice_sound] - pygame.mixer.Channel(1).play(sound) - parle("j'ai lancé " + playlist_text[indice_sound].split("/")[-1].replace(".mp3", ""), False) + process = Popen(["sound_player/player-client.py", "next"], stdout=PIPE, stderr=PIPE) + stdout, stderr = process.communicate() + parle("j'ai lancé " + stdout.split(":").strip(), False) if "musique precedente" in entre: - # os.system("rhythmbox-client --previous") - indice_sound = (indice_sound - 1) % len(playlist_sound) - sound = playlist_sound[indice_sound] - pygame.mixer.Channel(1).play(sound) - parle("j'ai lancé " + playlist_text[indice_sound].split("/")[-1].replace(".mp3", ""), False) + process = Popen(["sound_player/player-client.py", "previous"], stdout=PIPE, stderr=PIPE) + stdout, stderr = process.communicate() + parle("j'ai lancé " + stdout.split(":").strip(), False) if "nom de la musique" in entre: - # process = Popen(["rhythmbox-client", "--print-playing"], stdout=PIPE, stderr=PIPE) - # stdout, stderr = process.communicate() - parle("j'ai lancé " + playlist_text[indice_sound].split("/")[-1].replace(".mp3", ""), False) + process = Popen(["sound_player/player-client.py", "get_sound"], stdout=PIPE, stderr=PIPE) + stdout, stderr = process.communicate() + parle(stdout.split(":").strip(), False) # gestion du volume if "monte" in entre and any(e in entre for e in ["son", "volume"]): - # os.system("pactl -- set-sink-volume 0 +10%") - # os.system("rhythmbox-client --volume-up") - pygame.mixer.Channel(1).set_volume(pygame.mixer.Channel(1).get_volume() + 10) - print("[!] music volume :", pygame.mixer.Channel(1).get_volume()) + process = Popen(["sound_player/player-client.py", "volume_up"], stdout=PIPE, stderr=PIPE) + stdout, stderr = process.communicate() + parle("volume : " + int(float(stdout.split(":").strip()) * 100), False) if "baisse" in entre and any(e in entre for e in ["son", "volume"]): - # os.system("pactl -- set-sink-volume 0 -10%") - # os.system("rhythmbox-client --volume-down") - pygame.mixer.Channel(1).set_volume(pygame.mixer.Channel(1).get_volume() + 10) - print("[!] music volume :", pygame.mixer.Channel(1).get_volume()) + process = Popen(["sound_player/player-client.py", "volume_down"], stdout=PIPE, stderr=PIPE) + stdout, stderr = process.communicate() + parle("volume : " + int(float(stdout.split(":").strip()) * 100), False) # éteind le pc # if "eteint" in entre and "ordinateur" in entre: # Eteint l'ordinateur diff --git a/launch_jarvis.sh b/launch_jarvis.sh index e7e16a22578d1ae28d5dbae094d737969e435a11..22d5ed867a3b38213e056367d55313d69e811692 100644 --- a/launch_jarvis.sh +++ b/launch_jarvis.sh @@ -1,3 +1,5 @@ #!/bin/bash -screen -S sound_player -d -m sudo sound_player/sound_player.py +cd /home/pi/jarvis/sound_player +screen -S sound_player -d -m sudo ./player.py +cd .. screen -S jarvis -d -m ./Jarvis.py \ No newline at end of file