User avatar
JonnyAlpha
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 572
Joined: Sat Nov 02, 2013 2:06 pm

Playing a beep using Python

Sat Nov 14, 2015 10:40 am

Hi;

I have been asked a question that I cant find the answer to.

Can you / how do you play a sound using python, but not from a sound file i.e. can you use Python to generate a sound?

Thanks in advance
Raspberry Pi Certified Educator. Main Hardware - Raspberry Pi 1 model B revision 2, Raspberry Pi 2 model B, Pi Camera

User avatar
JonnyAlpha
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 572
Joined: Sat Nov 02, 2013 2:06 pm

Re: Playing a beep using Python

Sat Nov 14, 2015 10:54 am

Sorry the gentleman is trying to use print "\a"
Raspberry Pi Certified Educator. Main Hardware - Raspberry Pi 1 model B revision 2, Raspberry Pi 2 model B, Pi Camera

User avatar
Laurens-wuyts
Posts: 716
Joined: Wed Aug 21, 2013 7:35 pm
Location: Belgium
Contact: Website

Re: Playing a beep using Python

Sat Nov 14, 2015 11:15 am

You can try:

Code: Select all

print('\a')
Which is working in Windows 10. ;)
I'm not sure if it produces a sound on a RPi. :?

Laurens

User avatar
JonnyAlpha
Raspberry Pi Certified Educator
Raspberry Pi Certified Educator
Posts: 572
Joined: Sat Nov 02, 2013 2:06 pm

Re: Playing a beep using Python

Sun Nov 15, 2015 11:41 am

Thanks Laurens I think that is the problem, this line of code does not result in a sound from the Pi.
Raspberry Pi Certified Educator. Main Hardware - Raspberry Pi 1 model B revision 2, Raspberry Pi 2 model B, Pi Camera

User avatar
Laurens-wuyts
Posts: 716
Joined: Wed Aug 21, 2013 7:35 pm
Location: Belgium
Contact: Website

Re: Playing a beep using Python

Sun Nov 15, 2015 11:47 am

You can try what's mentioned here. ;)

Laurens

Return to “Python”