Skip to main content

Python

Raspberry Pi audio playback from Python

Want to play audio on your Raspberry Pi running Raspbian, while logged in to a non-root user account? Me, too!

Seems like such a simple task.

Consider the following code snippet using PyGame:

import time
import pygame
pygame.mixer.init()
pygame.mixer.music.load("testfile.wav")
pygame.mixer.music.play()
while pygame.mixer.music.get_busy() == True:
    time.sleep(.25)

Let's try it:

$ python soundtest.py
Traceback (most recent call last):
  File "./soundtest.py", line 3, in <module>
    pygame.mixer.init()
pygame.error: No available audio device

Automating vote tallying on the Google+ "Light Box" community: The TallyBot

The Light Box is a Google+ community that allows people to submit photos for community review. Qualified community members 'vote' on photos by leaving a comment with sequential hashtags like "#delete1", "#delete2", "save5", etc. The when the saves or deletes reach 10, we have a winner (the first to reach the threshold wins.)

Twitter Streaming API utility for Python

I've released twitter-streamer ("Streamer") under the MIT license.

Streamer is a simple Python script that dumps tweets using Twitter's streaming API via the statuses/filter method.

Syndicate content