
Stories = os.listdir(dir_path + "/stories") Speak("news from " + source, 'feedintro')įor idx, post in enumerate(parse.entries):įeed = post.title + " : " + scription + "\n" Joke = submission.title + lftextĮlif "black" in joke or "wife" in joke or "blonde" in joke or "jew" in joke: Tts.save(dir_path + "/" + str(filename) + ".mp3")įor submission in subreddit.hot(limit=99): #5 = radio menu, 6 = play menu, 7 = alarm settings, 8 = story play, 9 = music play, 10 = set volume# #menu variable: 1 = main, 2 = settings, 3 = alarm mode, 4 = set radio,
MPLAY PYGAME PASSWORD
Reddit = praw.Reddit(client_id = "XXXXXXX", client_secret = "XXXXXXX", password = "XXXXXX", username = "XXXXXX", user_agent = "XXXXXXX")


tup(5, GPIO.IN, pull_up_down=GPIO.PUD_UP) tup(6, GPIO.IN, pull_up_down=GPIO.PUD_UP) tup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP) tup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP) #!/usr/bin/env python3ĭir_path = os.path.dirname(os.path.realpath(_file_)) Apologies it’s quite long, probably the only significant parts are the play() function and the main loop, but wanted to include everything just in case. The script is basically meant to be a radio alarm with some additional functions. Thanks gadgetoid, I’ll have a look at your VLC package. Spent a long time trying to set Pyglet up last night only to discover that it will only play mp3 with AVBin, which seems to be unavailable for the Pi. Has anyone else encountered this/have ideas for a fix? Also happy to hear suggestions for an alternative audio library that will play mp3 (ideally stream internet radio also), pause, change volume, seek.

CPU doesn’t usually exceed 10% when running the script and I’ve tried increasing the buffersize for both the pygame mixer and in nf. And eventually this one pops up: ‘ALSA write failed (unrecoverable): File descriptor in bad state’ which makes the hat stop working with the python script, requiring me to restart the script. However, I frequently get underrun errors: ‘ALSA lib pcm.c:7843:(snd_pcm_recover) underrun occurred’ (1-4 pop up every minute) which disrupt the audio slightly. I have a python3 script that loops every 0.1 seconds and I want it running constantly. If ( not channel2.Have recently hooked up the speaker pHAT and enjoying it a lot! However, I’m having a problem with the hat ‘disconnecting’ after some time when using the pygame audio mixer. Rain_sound = ( 'rain-falling.ogg' )Ĭay( rain_sound, -1 ) # loop the rain sound forever # create separate Channel objects for simultaneous playbackĬhannel1 = (0) # argument must be int Window = _mode( ( WINDOW_WIDTH, WINDOW_HEIGHT ), WINDOW_SURFACE ) WINDOW_SURFACE = pygame.HWSURFACE|pygame.DOUBLEBUF|pygame.RESIZABLE

MPLAY PYGAME CODE
Like the linked code it continuously plays a rain-sound, and pressing h adds a car horn meep-meep into the output. I have adapted the example from the comment link to not use the var module.
MPLAY PYGAME SOFTWARE
Free software such as Audacity is easily able to convert sound formats. Obviously this is not a solution if you want to write an MP3 music player, but for a game it's a minor a requirement. However, it's absolutely possible to convert your sound-files to OGG sound format - which is compressed much the same as MP3, or the uncompressed WAV format. They can be played singularly with the set of functions. It's not possible to play multiple MP3 sound files simultaneously using channels with PyGame. Just so there's a formal answer to this question.
