Process.run() hangs if the result is too long

Hi, I'm trying to download an audio file with curl and then send the data to an audioshield. When use something tiny like a 2-second ogg file, it works as expected. But when the files is of any significant length, it seems to hang at process.run()

Here's the relevant bit of code:

 Process p;
  Serial.println("begin");
  p.begin("curl");

  Serial.println("addParameters");
  p.addParameter("--insecure"); // the Yun doesn't recognize the CA on IBM's ssl cert, it exits with CURLE_SSL_CACERT (60)
  p.addParameter("--user");
  p.addParameter(TTS_USERNAME + ":" + TTS_PASSWORD);
  p.addParameter("-H");
  p.addParameter("Accept: audio/wav"); // or audio/ogg; codec=opus, but the vs1053b can't decode opus (yet)
  p.addParameter("https://stream.watsonplatform.net/text-to-speech-beta/api/v1/synthesize?text=Hello%20world");

  Serial.println("run");
  p.run();		// Run the process and wait for its termination
  
  Serial.println("setting up music player");
  //...

If I switch it to ogg, then the file is only ~19kb and it gets sent to the mp3 shield (which apparently can't play ogg/opus at the moment). But if I switch it to wav format, then the file is ~200kb and my "setting up music player" line never gets logged.

Any ideas? Would the asynchronous version make a difference here?

ShapeShifter said

This is a problem with the Bridge library and version 1.6.3 of the IDE. The solution is to upgrade the bridge library: http://forum.arduino.cc/index.php?topic=316640.0

Jesse

nfriedly:
Would the asynchronous version make a difference here?

Perhaps. The way you are doing a synchronous run, all of the data needs to be read and stored in RAM somewhere. I’m not sure how that is managed, but it’s conceivable that the pipe/queue/whatever is filling up and stalling, so the process never completes.

If run asynchronously, your sketch can start pullng data out of the Process object, even before it is done, and that may allow it complete?

Or perhaps you can cone up with a Linux command to get the file and download it an SD card file, and then your sketch opens that file and streams it to the shield?

Another option may be to use a USB audio adapter instead of the shield, which would be managed by Linux. In that way, the entire process can be handled by Linux without it all having to go through the sketch - might be easier and more efficient?

@OP;-

How did you manage to access watsonplatform API without pass user credential?

working for IBM? :wink:

sonnyyu:
How did you manage to access watsonplatform API without pass user credential?

Did you miss this line in his sketch?

 p.addParameter(TTS_USERNAME + ":" + TTS_PASSWORD);

ShapeShifter:
Did you miss this line in his sketch?

 p.addParameter(TTS_USERNAME + ":" + TTS_PASSWORD);

I missed that. now second question how to obtain TTS_USERNAME / TTS_PASSWORD.