Skip to content
Extraits de code Groupes Projets
Valider 4fe1bc09 rédigé par Loïc Wikle DUBARD's avatar Loïc Wikle DUBARD
Parcourir les fichiers

bon ben pygame pour le lecteur de musique n'a pas l'air de fonctionner correctement

parent 5ed7e08f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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)
Aucun aperçu pour ce type de fichier
......@@ -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):
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter