Search code examples
javaserializationpepper

Create an audio file from what Pepper robot listen


I want to create a file with something that Pepper robot hear in a limited period of time. All at all, how I can create a .wav file containing the pepper listening? Actually, I used ALAudioRecorder NaoQi library, but I have faced with below error about serialize return value.

import com.aldebaran.qi.Application;
import com.aldebaran.qi.helper.proxies.ALAudioRecorder;
public class helloWord {

  public static void main(String[] args) throws Exception {
    String robotUrl = "tcp://pepper.local:9559";/*pepper.local.:9559*/
    Application application = new Application(args, robotUrl);
    application.start();
    boolean[] array =  {false,false,true,false};
   ALAudioRecorder alAudioRecorder=new ALAudioRecorder(application.session());
   alAudioRecorder.startMicrophonesRecording("D:/test/test.wav", "wav",48000,array);}}





 Exception in thread "main" java.lang.RuntimeException: Cannot serialize return value: Unable to convert JObject in AnyValue
at com.aldebaran.qi.Future.get(Future.java:96)
at com.aldebaran.qi.helper.proxies.ALAudioRecorder.startMicrophonesRecording(ALAudioRecorder.java:185)
at helloWord.main(helloWord.java:26)

Solution

  • As Alexandre said, your problem is here:

    alAudioRecorder.startMicrophonesRecording("D:/test/test.wav", "wav",48000,array);}}

    As the audio recorder service is running on the robot, it won't access your D: path, you need a path on the robot's (unix) filesystem like "/home/nao/test.wav".