The Raspberry Pi and the book monster – Session 4

Session 4 took place at the Innovation Centre as we needed access to some quality microphones and speakers.

In this session we quickly recapped the previous session and then discussed that the Book Monster would talk to the children when books were posted. To do this we needed to create some audio files that could be randomly played and we used the free audio software Audacity to do this.

We practiced recording our voices with Audacity to make sure the sound levels were okay and then learnt how to clip the beginning and end of the clip where necessary.

audio file example

Next we drafted several phrases we wanted the monster to say and then practised them in our best Monster voices. Once we were happy with them we recorded them carefully and then exported the files as MP3 files and saved them to the SD card we used with the Raspberry Pi.

Once completed we put the SD card back in the Pi, connected it up and turned it on.

We located the files on the SD card and copied them to a folder we created on the desktop of the Pi to use in our next piece of code.

We discussed how sound could be played and the code we could use as below.

import pygame ## this is library for graphics and sound
import time ## Import ‘time’ library. Allows us to use ‘sleep’
pygame.mixer.init() ## initialises the pygame mixer
pygame.mixer.music.set_volume(20.0) ## set the maximum volume
pygame.mixer.music.load(‘your mp3 filename’) ## load your audio track
pygame.mixer.music.play() ## play your loaded audio file
time.sleep(5) ## wait 5 seconds
pygame.mixer.music.load(‘your mp3 filename’) ## load your next audio track
pygame.mixer.music.play() ## play your loaded audio file
time.sleep(5) ## wait 5 seconds

This code allowed us to play a couple of the clips we had recorded to see if it worked. It worked really well and all the groups were excited to hear their Monster Voices being used on the Pi.

Paul Scott

Curriculum Innovation manager working strategically with local, regional and national partners ensuring the service’s provision continually evolves to meet the needs of schools, the local community and businesses.

You may also like...