https://github.com/romanin-rf/seaplayer-audio
A library for async/sync playback audio.
https://github.com/romanin-rf/seaplayer-audio
asynchronous audio io module python seaplayer synchronous
Last synced: 6 months ago
JSON representation
A library for async/sync playback audio.
- Host: GitHub
- URL: https://github.com/romanin-rf/seaplayer-audio
- Owner: romanin-rf
- License: mit
- Created: 2024-06-06T15:46:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-10T17:12:19.000Z (9 months ago)
- Last Synced: 2025-04-10T23:52:05.266Z (6 months ago)
- Topics: asynchronous, audio, io, module, python, seaplayer, synchronous
- Language: Python
- Homepage: https://pypi.org/project/seaplayer-audio
- Size: 3.86 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# seaplayer-audio
## Description
The SeaPlayer library for async/sync playback audio.> ***The module is still under DEVELOPMENT, so I do not recommend using it in your projects.***
## Supported formats
It is based on the [sounddevice](https://github.com/spatialaudio/python-sounddevice) and [soundfile](https://github.com/bastibe/python-soundfile) module.
[soundfile](https://github.com/bastibe/python-soundfile), in turn, is a wrapper of the C library [libsndfile](https://github.com/libsndfile/libsndfile), which has limitations in file reading formats. [More info...](https://libsndfile.github.io/libsndfile/formats.html)
## Usage (synchronously)
#### Through context manager
```python
import time
from seaplayer_audio import CallbackSoundDeviceStreamer, FileAudioSourcedef main():
with FileAudioSource('example.mp3') as source:
with CallbackSoundDeviceStreamer() as streamer:
while len(data := source.readline(1)) > 0:
streamer.send( data )
time.sleep(0.01) # Optionalif __name__ == '__main__':
main()
```#### Through cycle
```python
import time
from seaplayer_audio import CallbackSoundDeviceStreamer, FileAudioSourcedef main():
file = FileAudioSource('example.mp3')
streamer = CallbackSoundDeviceStreamer()
streamer.start()
while len(data := source.readline(1)) > 0:
streamer.send( data )
time.sleep(0.01) # Optional
streamer.stop()
file.close()if __name__ == '__main__':
main()
```## Usage (asynchronously)
#### Through context manager
```python
import asyncio
from seaplayer_audio import AsyncCallbackSoundDeviceStreamer, AsyncFileAudioSourceasync def main():
async with AsyncFileAudioSource('example.mp3') as source:
async with AsyncCallbackSoundDeviceStreamer() as streamer:
while len(data := await source.readline(1)) > 0:
await streamer.send( data )
await asyncio.sleep(0.01) # Optionalif __name__ == '__main__':
asyncio.run(main())
```#### Through cycle
```python
import asyncio
from seaplayer_audio import AsyncCallbackSoundDeviceStreamer, AsyncFileAudioSourceasync def main():
file = FileAudioSource('example.mp3')
streamer = CallbackSoundDeviceStreamer()
await streamer.start()
while len(data := await source.readline(1)) > 0:
await streamer.send( data )
await asyncio.sleep(0.01) # Optional
await streamer.stop()
await file.close()if __name__ == '__main__':
asyncio.run(main())
```