Welcome, guest | Sign In | My Account | Store | Cart

This is a simple audio monitor that records about 1/2 second of sound then immediately plays it back in a continuous loop.

If you are testing with a laptop's, (etc), internal microphone be aware that acoustic feedback might occur...

This could be a use for your now aging netbook... ;o)

Bazza, G0LCU...

Python, 35 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Baby_Alarm.py
#
# A very crude baby alarm or audio monitor using standard text mode Python.
#
# A simple program that will do a short record of sound from either the internal
# microphone or an external one and immediately replay it in a continuous loop.
# It should work on ANY version of Python for Linux from at least 2.0.1, but untested.
#
# This is similar to this Linux shell veraion:-
# guest:~$ cat /dev/dsp > /dev/dsp<CR>
# Except that the shell version generates a byte string 32768 bytes in size.
# Debian 6.0.0, /dev/dsp existing and Python 2.6.0, 2.7.2, 3.1.3...
# PCLinuxOS 2009, /dev/dsp existing and Python 2.5.2, 3.1.2...
# If /dev/dsp does not exist then install oss-compat from your distro's repository...
# It also assumes that the _MIXER_ is set up correctly...
#
# This is ALL there is to it...
#
# Have fun messing with the sound system in its basic mode... ;o)

print("\nA simple pseudo-baby alarm idea for Linux...\n")
print("$VER: Baby_Alarm.py_Version_0.00.10_(C)2012_B.Walker_G0LCU.\n")
audio=open("/dev/dsp", "rb")
sound=open("/dev/dsp", "wb")
def main():
	while 1:
		try: sound.write(audio.read(4000))
		except KeyboardInterrupt: break
main()
print("\b\b\b\bQuiting...")
sound.close()
audio.close()

# End of program.
# Enjoy finding simple solutions to often very difficult problems.

Enjoy finding simple solutions to often very difficult problems...

Bazza, G0LCU...

Created by Barry Walker on Thu, 2 Aug 2012 (GPL)
Python recipes (4591)
Barry Walker's recipes (73)

Required Modules

  • (none specified)

Other Information and Tasks