System Beep?

DL Neil PythonList at DancesWithMice.info
Fri Mar 8 17:55:03 EST 2019


Steve,

On 9/03/19 11:03 AM, Steve wrote:
> I tried all three, nothing audio.  I am beginning to wonder if something I the operating system is at fault.
> The three lines do produce symbols.  The first two are a rectangle with a space in the middle and the last one spelled out "bel" in short/small characters.


You've piqued my interest. I haven't worked with sound using Python, but 
a future project, presently graphics/video, could easily expand...

I don't think it is an OpSys fault, per-se. Someone with some 
Python-audio, indeed Linux-audio (in my case) experience may well 
blow-apart my theory, but here goes (E&OE):

Python print()s to files. Normally the shell and a running program will 
print() to the screen. This can be piped or re-directed to a disk-file 
(for example). Thus, many such implementations have no bell to ring!

In the case of Linux, audio has long been problematic. Indeed there are 
Python interfaces to both Alsa and gstreamer. Ahah! Does this mean that 
the Python-OpSys relationship doesn't include sound, natively? ie that 
one interfaces?pipes sound to an audio sub-system rather than the OpSys 
itself.

Web-searching for "python sound" produces a number of 'hits'. A quick 
scan revealed a preference for working with audio files, eg mp3, wav; cf 
ASCII (or whatever) characters. I did come across 
https://pypi.org/project/kaching/ which offers similar facilities to 
those described earlier, from my mainframe days: "it worked", "it 
didn't", "you're a winner!".


A Linux 'solution' which led to my thinking (above):
ossaudiodev — Access to OSS-compatible audio devices
This module allows you to access the OSS (Open Sound System) audio 
interface. OSS is available for a wide range of open-source and 
commercial Unices, and is the standard audio interface for Linux and 
recent versions of FreeBSD.
https://docs.python.org/3/library/ossaudiodev.html
(presumably it relates to the Windows i/f others have mentioned)

A survey:
https://wiki.python.org/moin/Audio
(last edited three years ago)

No date on this one, but comments are very recent:
Play sound in Python
Play sound on Python is easy. There are several modules that can play a 
sound file (.wav).
These solutions are cross platform (Windows, Mac, Linux).
The main difference is in the ease of use and supported file formats. 
All of them should work with Python 3. The audio file should be in the 
same directory as your python program, unless you specify a path.
https://pythonbasics.org/python-play-sound/

Playsound 1.2.2 (last release nine months ago)
Pure Python, cross platform, single function module with no dependencies 
for playing sounds.
https://pypi.org/project/playsound/

Pypi has:
762 projects for "sound"
https://pypi.org/search/?q=sound

"Python and Sound" is a constructive tutorial which looks a bit old, but 
may suit your application (beyond BEL). However, it uses JES (which I 
came across years-and-years ago, but rejected because it is Java-based 
(bias alert!) which may/not be available for Python (or Jython!?) these 
days):
http://www.cs.uregina.ca/Links/class-info/325/PythonSound/index.html


-- 
Regards =dn



More information about the Python-list mailing list