Play and Record Sound with Python§
This Python module provides bindings for the PortAudio library and a few convenience functions to play and record NumPy arrays containing audio signals.
The sounddevice
module is available for Linux, macOS and Windows.
- Documentation:
- Source code repository and issue tracker:
- License:
MIT – see the file
LICENSE
for details.
click here to see full table of contents
- Installation
- Usage
- Example Programs
- Play a Sound File
- Play a Very Long Sound File
- Play a Very Long Sound File without Using NumPy
- Play a Web Stream
- Play a Sine Signal
- Input to Output Pass-Through
- Plot Microphone Signal(s) in Real-Time
- Real-Time Text-Mode Spectrogram
- Recording with Arbitrary Duration
- Using a stream in an
asyncio
coroutine - Creating an
asyncio
generator for audio blocks
- Contributing
- API Documentation
- Convenience Functions using NumPy Arrays
- Checking Available Hardware
- Module-wide Default Settings
- Platform-specific Settings
- Streams using NumPy Arrays
Stream
Stream.abort()
Stream.active
Stream.blocksize
Stream.channels
Stream.close()
Stream.closed
Stream.cpu_load
Stream.device
Stream.dtype
Stream.latency
Stream.read()
Stream.read_available
Stream.samplerate
Stream.samplesize
Stream.start()
Stream.stop()
Stream.stopped
Stream.time
Stream.write()
Stream.write_available
InputStream
OutputStream
- Raw Streams
- Miscellaneous
- Expert Mode
- Version History
How To Navigate This Site
Use the next and previous links at the top and the bottom of each page to flip through the pages. Alternatively, you can use the right and left arrow keys on your keyboard. Some additional keyboard shortcuts are provided via the accesskey feature: n next, p previous, u up (= to the parent page), i index, s search and m menu (= open/close sidebar).
Click on the hamburger button in the topbar to open and close the sidebar. The width of the sidebar can be adjusted by dragging its border. Click on the title in the topbar to scroll to the top of the page, if already at the top, go “up” to the parent page (eventually ending up on this very page).
On touch-enabled devices: Tap at the top of the page to show the topbar (if it was scrolled away); swipe from the left edge to show the sidebar, swipe towards the left to hide it.