From 4fe1bc09ccfb506067772a8a88d853305f3b38e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Wikle=20DUBARD?= <loic97429@gmail.com> Date: Sun, 29 Sep 2019 19:30:43 +0200 Subject: [PATCH] bon ben pygame pour le lecteur de musique n'a pas l'air de fonctionner correctement --- Jarvis.py | 20 ++++++++++---------- __pycache__/myimports.cpython-37.pyc | Bin 3171 -> 3486 bytes myimports.py | 3 ++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Jarvis.py b/Jarvis.py index 7e63cfe..17f8e2e 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 GIT binary patch delta 856 zcmaDXF;AM$iI<m)fq{YH*z*aoyLl(_NibGyRIg;LPi4(gU!aj9ks_HQl_I^6g^?je zCQ37%AxbMnHcC51E=nhrae?kahA6!ho>aYf{S^6By?BFE#w^1Wh7^Tf#weo{o+#rK z#VC^$r6|)BhA6WXhA8tChA4{^<rI}n#wg1a)fBZBhE&T1Rtp(i7@8TQtW(sZY*N&t zY*W;u>g`h0qwG^OQZ!Sv(wU<iQnXWaQgl=F(pjP$Q}j~|QVdg!QjAkfQcP3KQp{5< zQY_QCqnuKmQ>>a9`}v|=Qe76fE@X&u3uj1S3}gsmh+s&u23zL_w#wa|A;l)ewuK?Z zHr1n<Im$D|F2%luA<8SoA;qzUA<COAg)x{x(`j=C(-TIKOqVqb44EJP|NsAziGhJ3 zlYxVQVX_a)BQ`z;28JTO$tJ9}yxt5948<T>HijaR&2_B*8SATf3UU%Fb25ud^hzp9 zk{Ln4%)r0^QpCZ)z~Bthp~Aqxkj_xU5Gzy5Si+FSxPYmKaRKu}h6OAs3@MBYnHDlm zWGZ9{X3%81#mH48%D}*&$$E>epfWu%H}w{4Ze~SlQ50)%eraCHE!N_aqRfI@>_w>s zIf==snmSBHf(#4{w^)lo(nS!rf*dRiB19M%7}7v406B+^VR9{dvMNFem<3iR1NJb~ zZybz8GLsuQbSE2eNDF|~APC{fu^i&OxiBLc7>g7pH*$DmD!aoWB~*x{OcCTMpUE7Y znyf|Q3=9mDEji~f@=w0T*~4EX!N9-}#Zgd{8lRb$Su#13tBjF%@&hh2MuExV+(q>) z`30$Yw;0oIaTcW}rsQPir54}fg#~(iNoqyOEj~CG91OQOT`Q7P3raHc^NK)TD^dUj z2FM9W0R;9G$oIE6Y;yBcN^?@}SU?V5#K6G7!N|kN0fm#Va=SAz3Qd;bapGp?ViaQJ KV-{fHU;zL&ea))? delta 558 zcmbOy{aAv}iI<m)fq{Wx>4^!kZ+Is1Nif=MRIg;LPmzeyNN0%BOp%PzN|B1vPGwx6 zvydT5H-#rvH(oDAI#oAbKb0}dAcY}Crk63wFoh?|C`C5PI7KeXB!wZ$G=(9`EQKM; zJVic5A(Ju6B1JJpsf8icVu9sC1{a2A#we>4<tXbE<tUpJ<tW<}<tV!pl@!$!wRGkv z`xNyQPmL7K6s>fYD2Ej76rB{^6ulJv6oVAQ6r&X56q6LwbnYlecZL+R6!R8_6!TQ4 zX67j86pIwg7KSL76sr{L7KSL-6vki%O`FY2n4U0Bp2PBpjhBIep@?^K3#%=!7Xt%B zF%ts=0~<q;@aA)@{~0G&a3rfjRDhL%2q6$5%D}*o3RBL(SR^`$)58Rd!dpTGIf<3= z$@#ejMVZC%#rdUqDVZ>R42(sRlQ?xJujG`o!KPOfthXSs7)5(7l6ENu1_n*H$;@1u z9JkmCD$^5lQzsj8&0*x5e2%M!{T6F(W<_ez<V@}|MxMzJxXl>(CyVnG*>bv8B&QaX wWaj4;f&5V<3Gxxhs3L5x;IPTfPbtkwwPOKUJZth#p0LS*yiTmF0xTRX0Gs28N&o-= diff --git a/myimports.py b/myimports.py index 9d0f78b..989d1b6 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): -- GitLab