The winsound module is specific to Python installation on Windows operating system. The module defines following functions: Beep:When this function is called a beep is heard from the PC’s speaker.
I’ve made realtime audio visualization (realtime FFT) scripts with Python before, but 80% of that code was creating a GUI.I want to see data in real time while I’m developing this code, but I really don’t want to mess with GUI programming. I then had a crazy idea. Everyone has a web browser, which is a pretty good GUI with a Python script to analyze audio and save graphs (a lot of.
The function needs two parameters. The frequency parameter specifies frequency of the sound, and must be in the range 37 through 32,767 hertz. The duration parameter specifies duration of sound in. import winsound winsound.Beep(1000,500) MessageBeep:This function plays a sound as specified in the registry. The type argument specifies which sound to play. Possible values are:-1, MBICONASTERISK, MBICONEXCLAMATION, MBICONHAND, MBICONQUESTION, and MBOK (default).The value -1 produces a 'simple beep' winsound.MessageBeep PlaySound:This function Calls the underlying PlaySound function from the Platform API.
The function needs two parameters. The sound parameter may be a filename, a system sound alias, or audio data as a bytes-like object. Its interpretation depends on the value of flags. The flags are as defined below: SNDFILENAMEThe sound parameter is the name of a WAV file.SNDLOOPPlay the sound repeatedlySNDMEMORYThe sound parameter to PlaySound is a memory image of a WAV file, as a bytes-like object.SNDASYNCReturn immediately, allowing sounds to play asynchronously.SNDNODEFAULTIf the specified sound cannot be found, do not play the system default sound.SNDNOSTOPDo not interrupt sounds currently playing.Following statement plays the given WAV file. winsound.PlaySound('sample.wav', winsound.SNDFILENAME winsound.SNDNOWAIT) SNDALIAS:The Windows registry keys are associated with sound names.If the registry contains no such name, play the system default sound unless SNDNODEFAULT.
All Win32 systems support the following: PlaySound nameCorresponding Control Panel Sound name'SystemAsterisk'Asterisk'SystemExclamation'ExclamationSystemExit'Exit Windows'SystemHand'Critical StopSystemQuestion'QuestionFor example following statement plays Windows Exit sound. winsound.PlaySound('SystemExit', winsound.SNDALIAS)The winsound module also defines following sounds MBICONASTERISKPlay the SystemDefault sound.MBICONEXCLAMATIONPlay the SystemExclamation sound.MBICONHANDPlay the SystemHand sound.MBICONQUESTIONPlay the SystemQuestion sound.MBOKPlay the SystemDefault sound.