

There are 178 other projects in the npm registry using play-sound. Start using play-sound in your project by running npm i play-sound. Latest version: 1.1.5, last published: 7 months ago. To run the following examples with top-level await expressions, launch an asynchronous Python REPL using python3 -m asyncio or an IPython shell. Play audio files by shelling out to available audio tool. Synchronous API Play a file from play_sounds import play_file, DEFAULT_SONG play_file ( DEFAULT_SONG ) # blocks by default # play without blocking play_file ( DEFAULT_SONG, block = False ) Play while work completes from time import sleep from play_sounds import play_while_running, DEFAULT_SONG with play_while_running ( DEFAULT_SONG ): sleep ( 60 ) Play a file after work completes from time import sleep from play_sounds import play_after, DEFAULT_SOUND with play_after ( DEFAULT_SOUND ): # blocks by default sleep ( 60 ) # play without blocking with play_after ( DEFAULT_SOUND, block = False ): sleep ( 60 ) Ring the terminal bell from play_sounds import bell, bell_after # play bell bell () # ensure the bell is played even if an exception is thrown with bell_after (): raise Exception ( "Bye" ) Asynchronous API There's a synchronous API and an asynchronous API that you can use with the async/await syntax and asyncio. It can use aiopath.AsyncPath objects, too. This library uses pathlib.Path objects when pointing to filenames and paths.
#Play sounds install
Installation $ python3 -m pip install play_sounds If you're targeting multiple desktop platforms and don't want to get mired down in the details of when and where to use playsound or boombox, or if your project uses async/await, you can just reach for play_sounds and call it a day.


Neither boombox or playsound provide asyncio and async/await compatible APIs, but play_sounds does. playsound will play other formats than WAV on Windows, but it requires GStreamer and PyGObject bindings on Linux, while boombox has several playback backends for Linux other than, and including, GStreamer. Rationaleīoombox is great and 90% of the way there, however it is limited to only playing WAV files on Windows.
#Play sounds code
It includes a synchronous API and an equivalent asynchronous API.įor code examples, you can check out onhold and ding, or scroll down to the Usage section. If you can’t find the resource you need here, visit our contact page to get in touch.Įstablished in 1962, the MIT Press is one of the largest and most distinguished university presses in the world and a leading publisher of books and journals at the intersection of science, technology, art, social science, and design.Play_sounds provides a simple cross-platform API to play sounds in Python scripts. The MIT Press has been a leader in open access book publishing for over two decades, beginning in 1995 with the publication of William Mitchell’s City of Bits, which appeared simultaneously in print and in a dynamic, open web edition.Ĭollaborating with authors, instructors, booksellers, librarians, and the media is at the heart of what we do as a scholarly publisher. Today we publish over 30 titles in the arts and humanities, social sciences, and science and technology. MIT Press began publishing journals in 1970 with the first volumes of Linguistic Inquiry and the Journal of Interdisciplinary History. International Affairs, History, & Political Science.MIT Press Direct is a distinctive collection of influential MIT Press books curated for scholars and libraries worldwide.
