mhthies / pulsectl-asyncio Goto Github PK
View Code? Open in Web Editor NEWAsyncio frontend for pulsectl, a Python bindings library for PulseAudio (libpulse)
Home Page: https://pypi.org/project/pulsectl-asyncio/
License: MIT License
Asyncio frontend for pulsectl, a Python bindings library for PulseAudio (libpulse)
Home Page: https://pypi.org/project/pulsectl-asyncio/
License: MIT License
Can this library be used to play a wav file and capture the audiostream's playback/recording amplitude?
https://freedesktop.org/software/pulseaudio/doxygen/streams.html
I need to do something like this
https://thumbs.gfycat.com/AgonizingThinAustralianfreshwatercrocodile-max-1mb.gif
For your FFI you define timeval as follows:
class timeval(c.Structure):
_fields_ = [
('tv_sec', c.c_longlong),
('tv_usec', c.c_long),
]
This is, unfortunately not portable as tv_sec
is of type time_t
which may also be c_long
(as it is in my case), and then overflowing like this later on:
File "/usr/lib/python3.6/selectors.py", line 445, in select
fd_event_list = self._epoll.poll(timeout, max_ev)
OverflowError: timestamp too large to convert to C _PyTime_t
because the upper bytes are undefined. Forcing c_long
instead helps in my case but i suspect this is also not more portable - even though one might get away with it...
Hi! I'm using the library to create an Ubuntu service that connects with Pulse Audio and automatically ducks music applications when something else is running.
When I run the script, it runs perfectly, but when I run it as a service, it fails to connect with the Pulse Audio server. Any ideas why please? This is the traceback:
Mar 08 21:52:11 nitro python[47240]: Traceback (most recent call last):
Mar 08 21:52:11 nitro python[47240]: File "/path/to/venv/lib/python3.8/site-packages/pulsectl_asyncio/pulsectl_async.py", line 129, in connect
Mar 08 21:52:11 nitro python[47240]: c.pa.context_connect(self._ctx, self.server, flags, None)
Mar 08 21:52:11 nitro python[47240]: File "/path/to/venv/lib/python3.8/site-packages/pulsectl/_pulsectl.py", line 673, in _wrapper
Mar 08 21:52:11 nitro python[47240]: raise self.CallError(*err)
Mar 08 21:52:11 nitro python[47240]: pulsectl._pulsectl.CallError: ('pa_context_connect', (<pulsectl._pulsectl.LP_PA_CONTEXT object at 0x7ff96e34aa40>, None, 1, None), -1, 'Connection refused [pulse errno 6]')
Mar 08 21:52:11 nitro python[47240]: The above exception was the direct cause of the following exception:
Mar 08 21:52:11 nitro python[47240]: Traceback (most recent call last):
Mar 08 21:52:11 nitro python[47240]: File "/path/to/main.py", line 81, in <module>
Mar 08 21:52:11 nitro python[47240]: loop.run_until_complete(main())
Mar 08 21:52:11 nitro python[47240]: File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
Mar 08 21:52:11 nitro python[47240]: return future.result()
Mar 08 21:52:11 nitro python[47240]: File "/path/to/main.py", line 17, in main
Mar 08 21:52:11 nitro python[47240]: async with pulsectl_asyncio.PulseAsync('volume-increaser') as pulse:
Mar 08 21:52:11 nitro python[47240]: File "/path/to/venv/lib/python3.8/site-packages/pulsectl_asyncio/pulsectl_async.py", line 163, in __aenter__
Mar 08 21:52:11 nitro python[47240]: await self.connect()
Mar 08 21:52:11 nitro python[47240]: File "/path/to/venv/lib/python3.8/site-packages/pulsectl_asyncio/pulsectl_async.py", line 136, in connect
Mar 08 21:52:11 nitro python[47240]: raise PulseError('Failed to connect to pulseaudio server') from e
Mar 08 21:52:11 nitro python[47240]: pulsectl.pulsectl.PulseError: Failed to connect to pulseaudio server
This is my service:
[Unit]
Description=Auto-ducker
After=multi-user.target
[Service]
Type=simple
Restart=always
ExecStart=/path/to/venv/bin/python /path/to/main.py
[Install]
WantedBy=multi-user.target
I have tried:
async with pulsectl_asyncio.PulseAsync('volume-increaser', server='pulseaudio') as pulse:
), it fails to connect.User=nicholas
and Group=nicholas
, my user and user group.In both cases, the server fails to connect to the pulseaudio server.
guess, it should be:
[options]
packages = pulsectl_asyncio
python_requires = >=3.6
install_requires =
pulsectl >=23.5.0,<=23.5.1
include_package_data = True
or currently:
[options]
packages = pulsectl_asyncio
python_requires = >=3.6
install_requires =
pulsectl >=23.5.0,<=23.5.2
include_package_data = True
in setup.cfg?
else it can't be satisfied, it think...
Python 3.11.3 on Arch Linux
File "/usr/lib/python3.11/site-packages/pulsectl_asyncio/__init__.py", line 1, in <module>
from .pulsectl_async import PulseAsync
File "/usr/lib/python3.11/site-packages/pulsectl_asyncio/pulsectl_async.py", line 66, in <module>
class PulseAsync(object):
File "/usr/lib/python3.11/site-packages/pulsectl_asyncio/pulsectl_async.py", line 311, in PulseAsync
card_profile_set_by_index = _pulse_method_call(
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/pulsectl_asyncio/pulsectl_async.py", line 303, in _pulse_method_call
func_args = list(inspect.getargspec(func or (lambda: None)))
^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.