static void makeSpeechCereproc(S text, S voice, File destMp3) ctex {
S format = "mp3";
S post = "" + htmlencode(voice) + "" + /*htmlencode*/(text) + "" + format + "\n" +
"";
S url = "https://www.cereproc.com/livedemo.php";
URL _url = new URL(url);
URLConnection conn = _url.openConnection();
conn.setRequestProperty("Content-Type", "text/plain;charset=UTF-8");
conn.setRequestProperty("Accept", "*/*");
conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
conn.setRequestProperty("Accept-Language", "en-US,en;q=0.8,de;q=0.6");
conn.setRequestProperty("Cookie", "has_js=1; Drupal.visitor.liveDemo=p86ffzyal3tvgqfr; _ga=GA1.2.1406621623.1444122980; _gat=1");
conn.setRequestProperty("Origin", "https://www.cereproc.com");
conn.setRequestProperty("Referer", "https://www.cereproc.com/");
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/44.0.2403.89 Chrome/44.0.2403.89 Safari/537.36");
conn.setDoOutput(true);
OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(post);
writer.flush();
S encoding = conn.getContentEncoding();
//print("Encoding: " + encoding);
S contentType = conn.getContentType();
//print("Content type: " + contentType);
byte[] response = loadBinaryPage(conn);
//print("Bytes read: " + response.length);
if ("gzip".equals(encoding))
response = gunzipBinaryData(response);
//print("Bytes unpacked: " + response.length);
S s = new String(response, "UTF-8");
//print(s);
S oggUrl = null;
L tok = htmlcoarsetok(s);
for (int i = 1; i < tok.size(); i += 2)
if (isTag(tok.get(i), "url")) {
oggUrl = tok.get(i+1);
break;
}
if (oggUrl == null) fail("No sound URL found");
byte[] ogg = loadBinaryPage(oggUrl);
saveBinaryFile(destMp3, ogg);
//print("Saved: " + destMp3.getAbsolutePath() + " (" + ogg.length + " bytes)");
}