diff --git a/Jarvis.py b/Jarvis.py index 7e63cfeabada2e5278c5cd4f15fe09ab29258223..17f8e2eece3be4247e7a31a2d7da9c0632e38267 100755 --- a/Jarvis.py +++ b/Jarvis.py @@ -76,15 +76,15 @@ def parle(texte, save=True, lang='fr-CA'): print(line_no) # mp3 = mutagen.mp3.MP3('saved_voice/{}.mp3'.format(line_no)) # frequency = mp3.info.sample_rate - if pygame.mixer.Channel(0).get_busy(): - pygame.mixer.Channel(0).stop() + if pygame.mixer.music.get_busy(): + pygame.mixer.music.stop() # pygame.mixer.quit() # pygame.mixer.init(frequency=frequency) try: - sound = pygame.mixer.Sound('saved_voice/{}.mp3'.format(line_no)) - # pygame.mixer.music.load('saved_voice/{}.mp3'.format(line_no)) - pygame.mixer.Channel(0).play(sound) - pygame.mixer.Channel(0).set_endevent() + # sound = pygame.mixer.Sound('saved_voice/{}.mp3'.format(line_no)) + pygame.mixer.music.load('saved_voice/{}.mp3'.format(line_no)) + pygame.mixer.music.play(sound) + pygame.mixer.music.set_endevent() except: print("ERROR: can't play audio") @@ -504,11 +504,11 @@ def tests(entre): if __name__ == "__main__": parle("Bonjour ! " + random.choice(["", "Vous allez bien aujourd'hui ?"])) - get_busy = pygame.mixer.Channel(0).get_busy() + get_busy = pygame.mixer.music.get_busy() currently_playing = get_busy """boucle principale""" while True: - get_busy = pygame.mixer.Channel(0).get_busy() + get_busy = pygame.mixer.music.get_busy() # booléen qui indique si l'ia est en train de parler # end_event = pygame.mixer.music.get_endevent() # booléen indique si l'ia a fini de parler currently_playing = get_busy @@ -526,9 +526,9 @@ if __name__ == "__main__": if currently_playing: print('[!]talkin...', end='') - print('vol:', pygame.mixer.Channel(0).get_volume()) + print('vol:', pygame.mixer.music.get_volume()) if currently_playing and 'stop' in entre: - pygame.mixer.Channel(0).stop() + pygame.mixer.music.stop() elif deverouillage(entre): tests(entre) diff --git a/__pycache__/myimports.cpython-37.pyc b/__pycache__/myimports.cpython-37.pyc index c7470415e6c41af67019bc141e60abeb0bbb3361..37f69819628a14adafbb7fa01f514f7e9836ad5b 100644 Binary files a/__pycache__/myimports.cpython-37.pyc and b/__pycache__/myimports.cpython-37.pyc differ diff --git a/myimports.py b/myimports.py index 9d0f78bff89eaaf8a7797d2540f08d148efcd8f5..989d1b6509807bd63a9734da8fe1df5569d175e1 100644 --- a/myimports.py +++ b/myimports.py @@ -53,6 +53,7 @@ else: pygame.init() pygame.mixer.init(frequency=25000) +pygame.mixer.pre_init(44100, -16, 2, 2048) # engine = pyttsx3.init() # voice = engine.getProperty('voices')[26] # the french voice # engine.setProperty('voice', voice.id) @@ -98,7 +99,7 @@ fonctionnalites = [ ] with open("playlist.txt") as f: playlist_text = f.readlines() -playlist_sound = [pygame.mixer.Sound(sound.strip().replace("\n", "")) for sound in playlist_text] +# playlist_sound = [pygame.mixer.Sound(sound.strip().replace("\n", "")) for sound in playlist_text] class BreakoutException(Exception):