rhasspy / wyoming-satellite

Remote voice satellite using Wyoming protocol
MIT License
591 stars 86 forks source link

Usage Pixel Ring on ReSpeaker Core V2 #52

Open Smarthome-Creator opened 8 months ago

Smarthome-Creator commented 8 months ago

Hello, I know it might be just a wish, but is it possible to use the Pixel Ring of the Core V2? Or can someone help me with this? I was able to bring my old Core V2 back to life thanks to this project: https://community.rhasspy.org/t/images-for-raspeaker-core-v2/4519. But since I just couldn't get Rhasspy to run with HA, I tried the Wyoming satellite.

And it even still runs on the old device. At least what the 32-bit platform still allows. If the Pixel Ring still worked, the V2 would still be usable for some time.

llluis commented 8 months ago

It looks like the leds and connections are the same. So if you change the number of leds in the 2mic file from 3 to 12 and follow the tutorial it will work (all leds same color).

If this is confirmed it should be easy to implement the additional patterns. I like the idea and will try to find some time to do it for the 2mic.

Smarthome-Creator commented 8 months ago

@llluis, thanks for the tip, I'll give it a try.

atoulmin commented 8 months ago

How did you go getting this to work?

Smarthome-Creator commented 8 months ago

@atoulmin, the LEDs are currently not. As soon as I add the LEDs to the satellite service, I get error messages and then the wakeword recognition no longer works.

llluis commented 8 months ago

What errors are you getting ? Are you creating an event service to handle the leds and telling the satellite to connect to it?

mk-81 commented 7 months ago

Hello, if you follow the installer-tutorial you could try and choose the 4mic HAT in Feedback. I've searched the sources a bit and it might be, that the Core V2 has the same interface as the 4mic HAT (12 LEDs etc...). At least I didn't find a special implementation for the V2 in the reference example from seeedstudio. Might be worth a try.

Smarthome-Creator commented 7 months ago

@llluis, @mk-81, i have now got the 4Mic script running and the satellite and 4Mic service are up and running. But I cannot install the python3-spidev package because it is not available in the package sources for armhf (Debian 11). I assume this is why the errors occur. Journal Output:

-- Journal begins at Sun 2023-06-18 14:56:09 UTC. -- Jan 23 21:48:02 v2 python3[6400]: File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 486, in <module> Jan 23 21:48:02 v2 python3[6400]: Device.pin_factory = _default_pin_factory() Jan 23 21:48:02 v2 python3[6400]: File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 453, in _default_pin_factory Jan 23 21:48:02 v2 python3[6400]: raise BadPinFactory('Unable to load any default pin factory!') Jan 23 21:48:02 v2 python3[6400]: gpiozero.exc.BadPinFactory: Unable to load any default pin factory! Jan 23 21:48:02 v2 systemd[1]: 4mic_leds.service: Main process exited, code=exited, status=1/FAILURE Jan 23 21:48:02 v2 systemd[1]: 4mic_leds.service: Failed with result 'exit-code'. Jan 23 21:48:03 v2 systemd[1]: 4mic_leds.service: Scheduled restart job, restart counter is at 270. Jan 23 21:48:03 v2 systemd[1]: Stopped 2Mic LEDs. Jan 23 21:48:04 v2 systemd[1]: Started 2Mic LEDs. Jan 23 21:48:05 v2 python3[6407]: /usr/lib/python3/dist-packages/gpiozero/devices.py:450: PinFactoryFallback: Falling back from rpigpio: This module can only be run on a Raspberry Pi! Jan 23 21:48:05 v2 python3[6407]: warnings.warn( Jan 23 21:48:05 v2 python3[6407]: /usr/lib/python3/dist-packages/gpiozero/devices.py:450: PinFactoryFallback: Falling back from rpio: No module named 'RPIO' Jan 23 21:48:05 v2 python3[6407]: warnings.warn( Jan 23 21:48:05 v2 python3[6407]: /usr/lib/python3/dist-packages/gpiozero/devices.py:450: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio' Jan 23 21:48:05 v2 python3[6407]: warnings.warn( Jan 23 21:48:05 v2 python3[6407]: /usr/lib/python3/dist-packages/gpiozero/devices.py:450: PinFactoryFallback: Falling back from native: unable to determine RPi revision Jan 23 21:48:05 v2 python3[6407]: warnings.warn( Jan 23 21:48:05 v2 python3[6407]: Traceback (most recent call last): Jan 23 21:48:05 v2 python3[6407]: File "/home/respeaker/wyoming-satellite/examples/4mic_service.py", line 11, in <module> Jan 23 21:48:05 v2 python3[6407]: import gpiozero Jan 23 21:48:05 v2 python3[6407]: File "/usr/lib/python3/dist-packages/gpiozero/__init__.py", line 22, in <module> Jan 23 21:48:05 v2 python3[6407]: from .devices import ( Jan 23 21:48:05 v2 python3[6407]: File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 486, in <module> Jan 23 21:48:05 v2 python3[6407]: Device.pin_factory = _default_pin_factory() Jan 23 21:48:05 v2 python3[6407]: File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 453, in _default_pin_factory Jan 23 21:48:05 v2 python3[6407]: raise BadPinFactory('Unable to load any default pin factory!') Jan 23 21:48:05 v2 python3[6407]: gpiozero.exc.BadPinFactory: Unable to load any default pin factory! Jan 23 21:48:05 v2 systemd[1]: 4mic_leds.service: Main process exited, code=exited, status=1/FAILURE Jan 23 21:48:05 v2 systemd[1]: 4mic_leds.service: Failed with result 'exit-code'. Jan 23 21:48:06 v2 systemd[1]: 4mic_leds.service: Scheduled restart job, restart counter is at 271. Jan 23 21:48:06 v2 systemd[1]: Stopped 2Mic LEDs. Jan 23 21:48:06 v2 systemd[1]: Started 2Mic LEDs. This then goes on and on.

mk-81 commented 7 months ago

Hello smarthome-Creator,

gpiozero is used to enable le LEDs on 4mic HAT via GPIO. Unfortunately, gpiozero is only relevant for raspberry pi (according to documentation). ReSpeaker Core V2 is something of its own. That I missed yesterday. Unfortunately, this also means you have to port the implementation. If you can do that depends on how fit you are in development.

In https://github.com/respeaker/pixel_ring/blob/master/pixel_ring/__init__.py is the correct init sequence for the CoreV2. Out of interest I've read the documentation for ReSpeaker Core V2 yesterday.

I've modified the 4mic script. Relevant sections marked with ### adjustment Core V2. I don't know if this will work. I've simply took it from documentation. So it might work - or not. So give it a try if you like. 4mic_service.py.txt

Ah, one thing which you might not see directly. I had to upload the file as .txt (for security reasons obviously). You have to correct this beforehand.

regards

Smarthome-Creator commented 7 months ago

@mk-81 , thank you for all your support. I will test it and then report back.

Smarthome-Creator commented 7 months ago

Hello @mk-81 , I have tested it. I think it would work but I can't get the pixelring to run because "mraa" can't be imported. Which is strange, because it is installed.

Why do I assume that it works... The creator of the images has made it possible to use Rhasspy and Hermes LED Control. And because Rhasspy and Wyoming are somehow connected, maybe it is possible after all.

But thanks for your help, I'll keep trying.

mk-81 commented 7 months ago

Hello Smarthome-Creator,

I assume that mraa ist installed as a global package. Wyoming-satellite use an own virtual environment. Default without access to the system site packages. I've tried, but it seems that a package named mraa ist not available on pypi for installation in the virtual environment. Maybe you test beforehand, that the python package mraa really is available. You should be able to test like so:

` :~# python3 Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import mraa

Traceback (most recent call last): File "", line 1, in ModuleNotFoundError: No module named 'mraa'

>>> quit( ) `

I do not have mraa because I'm on a PI and hence the import error. You should not get any error message. If this works, you could try to modify the file script/setup and change venv.EnvBuilder(with_pip=True) to venv.EnvBuilder(with_pip=True, system_site_packages=True), delete the virtual environment (the .venv folder) and run script/setup again and see what happens.

Regards

Smarthome-Creator commented 7 months ago

@mk-81 I have now discovered something similar in my experiments. Pretty much the same thing. MRAA is not available as a pip installation package for Python 2 and 3.

I will test this with the modified script. Thanks for the tip.

----Edit---- I have now tested it again. The installation runs smoothly with the changed values. Unfortunately, "mraa" still cannot be imported into the Python3 .venv.

`● 4mic_leds.service - 4Mic LEDs Loaded: loaded (/etc/systemd/system/4mic_leds.service; disabled; vendor preset: enabled) Active: failed (Result: exit-code) since Thu 2024-02-15 21:20:18 UTC; 50s ago Process: 1954 ExecStart=/home/respeaker/wyoming-satellite/examples/.venv/bin/python3 4mic_service.py --uri tcp://127.0.0.1:10500 (code=exited, status=1/FAILURE) Main PID: 1954 (code=exited, status=1/FAILURE)

Feb 15 21:20:18 v2 systemd[1]: 4mic_leds.service: Scheduled restart job, restart counter is at 5. Feb 15 21:20:18 v2 systemd[1]: Stopped 4Mic LEDs.

respeaker@v2:~$ journalctl -u 4mic_leds.service -f -- Journal begins at Sun 2023-06-18 14:56:04 UTC. -- Feb 15 21:20:16 v2 python3[1954]: File "/home/respeaker/wyoming-satellite/examples/4mic_service.py", line 13, in Feb 15 21:20:16 v2 python3[1954]: import mraa Feb 15 21:20:16 v2 python3[1954]: ModuleNotFoundError: No module named 'mraa' Feb 15 21:20:16 v2 systemd[1]: 4mic_leds.service: Main process exited, code=exited, status=1/FAILURE Feb 15 21:20:16 v2 systemd[1]: 4mic_leds.service: Failed with result 'exit-code'. Feb 15 21:20:18 v2 systemd[1]: 4mic_leds.service: Scheduled restart job, restart counter is at 5. Feb 15 21:20:18 v2 systemd[1]: Stopped 4Mic LEDs. Feb 15 21:20:18 v2 systemd[1]: 4mic_leds.service: Start request repeated too quickly. Feb 15 21:20:18 v2 systemd[1]: 4mic_leds.service: Failed with result 'exit-code'. Feb 15 21:20:18 v2 systemd[1]: Failed to start 4Mic LEDs.`