3

I have been trying to run a python script to get Nao's audio as a stream

Found the example directly on aldebaran's website

http://doc.aldebaran.com/2-8/dev/python/examples/audio/audio_soundprocessing.html#process-microphone-signals

I am trying to run it as is with only my robot's proper IP. Once it gets to the startProcessing function, it cannot find the new service created in ALAudioDevice and gives the following error

self.audio_service.setClientPreferences(self.module_name, 16000, 3, 0)
RUNTIMEERROR:   ALPROXY::ALPROXY
        CANT FIND SERVICE: SoundProcessingModule
[W] 1609782681.228570 42712 QITYPE.SIGNAL: DISCONNECT: NO SUBSCRIPTION FOUND FOR SIGNALLINK 14. 

Any idea of what should change to be able to run that example?

LGG
  • 31
  • 2

1 Answers1

0

As you can see in the link you provided, prior to setting the audio client preferences, you must register your service (or "module") to NAOqi:

app.session.listen()
app.session.registerService("SoundProcessingModule", MySoundProcessingModule)

It is important that your service is registered prior to referring to it in other APIs such as setClientPreferences.

Victor Paléologue
  • 2,025
  • 1
  • 17
  • 27
  • Hey Victor, I'm new to this, but is that not what is happening? Starting SoundProcessingModule and registering it in the next line (second to last), before doing the startProcessing? Yet it still says it can't find the service. Should I register ir some other way? `File "SoundProcessingModule.py", line 113, in MySoundProcessingModule.startProcessing() File "SoundProcessingModule.py", line 42, in startProcessing self.audio_service.setClientPreferences(self.module_name, 16000, 3, 0) RuntimeError: ALProxy::ALProxy Can't find service: SoundProcessingModule` – LGG Jan 27 '21 at 18:39
  • The example has `app.session.registerService("SoundProcessingModule", MySoundProcessingModule)` right before `MySoundProcessingModule.startProcessing()`. In theory this should work, so I must assume something is wrong in your code. Please share it and/or your full backtrace to investigate your issue deeper. – Victor Paléologue Jan 28 '21 at 09:46
  • My current code is exactly the example code but with my robot's IP since I am running it from my computer and not from the robot itself. I just wanted first to test the example before doing any changes. I don't know why it is not working, let me know if I can post something that could give a better explanation of this. – LGG Feb 01 '21 at 22:40
  • Perhaps if you could share the logs of your program in a pastebin, and perhaps also of NAOqi, I could help further. – Victor Paléologue Feb 02 '21 at 10:54
  • I have the same issue. Registering the service in the robot works (i ssh and run the python code there ), but not from a pc. – user27221 Oct 02 '21 at 10:54
  • Also, if you list the service with `app.session.services()` the service is there on both the robot and the pc. Running from the robot, the service in the pc is also not found (same alproxy error). Sounds like a networking bug – user27221 Oct 02 '21 at 13:11
  • Ok, I think I understand, sorry but I forgot a part of the solution. With the code I gave, you are registering a service via a client socket, so the address is only available to the service directory (which runs the paired server socket), and not to other clients such as `ALAUdioDevice`. To make it available, the session running from the PC should start a server socket by calling `session.listen(address)`. Make sure the address (usually ip:port) is reachable for the robot. – Victor Paléologue Oct 04 '21 at 15:19
  • Do you have a complete working example you can show? – user27221 Oct 08 '21 at 17:09
  • No, but I updated my answer accordingly. However I tested the original sample with NAOqi 2.1 and it worked, but it is plausible that NAOqi 2.8 works differently. – Victor Paléologue Oct 11 '21 at 11:04
  • Please share your NAOqi logs if possible, there is something fishy in the fact that in https://stackoverflow.com/questions/69505667/how-do-you-use-a-different-speech-recognition-engine-with-nao you say you managed to use `ALMemory` events, which rely on the same mechanism. – Victor Paléologue Oct 19 '21 at 14:26
  • Did you find a solution to this? I run into the same issue when trying to do this inside a Docker container. The same code runs fine from the host PC though. – user1587520 Nov 25 '21 at 08:03
  • @user1587520 you have a different issue. You need your docker to open a port to so that the address you provide in the `session.listen(address)` is actually reachable from the robot. @user27221 is it possible that this is your issue? Did you check that you have no firewall blocking the port, or that you are not working in a VM? – Victor Paléologue Nov 26 '21 at 11:54
  • @VictorPaléologue Thanks for your answer, I tried to set `session.listen('0.0.0.0:9558')` and open that port on the container. The logs showed that it is used by the Session. I checked with telnet from the host machine that I connect to the port. I also tried to register a dummy service to the session in the container and tested that I can get and run it from a qi.Application that I started in the Python REPL on the Robot. That worked fine, even without opening the port on the container. Somehow it looks like there is still a different (dynamic) port used. Running directly on the host works. – user1587520 Nov 27 '21 at 13:51
  • @VictorPaléologue Code is here: https://github.com/leolani/cltl-backend-naoqi/blob/test/src/test_so.py – user1587520 Nov 27 '21 at 13:52
  • This test shows you are registered, but not that the `test` method can be called properly from the robot. You'll need another script on the robot to call that method to properly test the service registration. – Victor Paléologue Nov 28 '21 at 14:09
  • 1
    @VictorPaléologue Sorry, forgot to include the code on the robot. If we run `app = qi.Application(["Test App Robot", "--qi-url=localhost:9559"]) app.start() test_service = app.session.service("TestModule") test_service.test()` there it works, we see the invocation in the container and the result on the robot. I added to code to the link above as well. Nevertheless, if I register the SoundProcessingModule the same way in the container, the ALAudioDevice doesn't seem to see it. – user1587520 Nov 29 '21 at 11:50