Search code examples
pythonpython-2.7nao-robotpepper

Error when recording sound on Pepper robot


I want my Pepper robot to record a piece of audio using startMicrophonesRecording(). In NAOqi v2.5 it takes four arguments (path, type, hertz and microphones). Trying to run

AD.startMicrophonesRecording("/data/home/nao/recordings/microphones/test.wav","wav",16000,(0,0,1,0))

I however get the error message

RuntimeError: Arguments types did not match for startMicrophonesRecording (resolved to '(ssi(iiii))'): 
Candidate: 
  startMicrophonesRecording::(s) (1)

It seems that startMicrophonesRecording() only wants one argument. I can see in past versions of the function that it used to only take the file path as an argument, so maybe Python is looking at a past version of NAOqi for the modules?

I have tried setting PYTHONPATH to C:\Users\<user>\<path>\pynaoqi-python2.7-2.5.5.5-win32-vs2013\lib using this tutorial, but I still get the same error.

Any ideas as to what I can do?

Python 2.7 on Windows 10.


Solution

  • Did you try with one argument?

    The NAOqi v2.5 Link you named, refers to ALAudioRecorder and C++. The "old Version" refers to Python ALAudioDevice. An NAOqi v2.5 Python API for ALAudioDevice is described here.

    For me these python snippets works fine:

    ALAudioDevice:

    import naoqi
    from naoqi import ALProxy
    AD = ALProxy("ALAudioDevice", "pepper.local", 9559)
    AD.startMicrophonesRecording("/data/home/nao/recordings/microphones/test.wav")
    AD.stopMicrophonesRecording()
    

    ALAudioRecorder:

    import naoqi
    from naoqi import ALProxy
    AR = ALProxy("ALAudioRecorder", "pepper.local", 9559)
    AR.startMicrophonesRecording("/data/home/nao/recordings/microphones/test.wav","wav",16000,[0,0,1,0])
    AR.stopMicrophonesRecording()