wasdk / WebAssemblyStudio

Learn, Teach, Work and Play in the WebAssembly Studio
http://webassembly.studio
MIT License
2.92k stars 273 forks source link

How to build espeak-ng with two options set as default for resulting executable? #449

Closed guest271314 closed 4 years ago

guest271314 commented 4 years ago

How to build espeak-ng at WebAssembly Studio with two options set as default for resulting executable?

Requirement: Build espeak-ng with -m ("Interpret SSML markup, and ignore other \< > tags") and --stdout ("Write speech output to stdout") built in to the resulting executable (no other input options or output expected).

Expected result: espeakNG(<text_or_ssml>, callback) or espeakNG(<text_or_ssml>).then(callback).

Goal: Ability to achieve the same result as POSTing input to local server

<?php 
  if(isset($_POST["text_or_ssml"])) {
    header("Content-Type: audio/x-wav");
    $options = $_POST["options"];
    echo shell_exec("ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} src/espeak-ng -m --stdout " . $options . " '" . $_POST["text_or_ssml"] . "'");
  };

where input is

async function localEspeakNG(text_or_ssml = "", options = "") {
  try {
    const fd = new FormData();
    fd.append("text_or_ssml", text_or_ssml);
    fd.append("options", options);
    const request = await fetch("http://localhost", {method:"POST", body:fd})
    const response = await request.arrayBuffer();
    return response;
  } catch (e) {
      throw e;
  }
}

let ssml = `<speak version="1.0" xml:lang="en-US"> 
             Here are <say-as interpret-as="characters">SSML</say-as> samples. 
             Hello universe, how are you today? 
             Try a date: <say-as interpret-as="date" format="dmy" detail="1">10-9-1960</say-as> 
             This is a <break time="2500ms" /> 2.5 second pause. 
             This is a <break /> sentence break</prosody> <break />
             <voice name="en-french" rate="x-slow" pitch="0.25">espeak using</voice> 
             PHP and <voice name="English_(Lancaster)"> <sub alias="JavaScript">JS</sub></voice>
            </speak>`;

Can all of the required files be uploaded/written in the left panel, then set the specific 2 options as default, then build the wasm file?

Is the requirement and expected goal possible using WebAssembly Studio?