!7 p { // Try coughing //S text = [[cough I can now cough]]; S text = [[cough]]; //S text = [[Today, the sun is shining.]]; //S text = [[When people leave a tip they want to know it will // not be used to make up the minimum wage.]]; File credentialsFile = newFile(javaxSecretDir(), "cereproc.txt"); L secret = tlft(credentialsFile); assertEquals("Please give me " + f2s(credentialsFile), 2, l(secret)); String xml = "" +"" + first(secret) + "" +"" + second(secret) + "" +"Jess" +"" + text + ""; URL u = new URL("https://cerevoice.com/rest/rest_1_1.php"); URLConnection uc = openConnection(u); HttpURLConnection connection = (HttpURLConnection) uc; connection.setDoOutput(true); connection.setDoInput(true); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type","text/xml; charset=utf-8"); connection.setRequestProperty("Content-Length", String.valueOf(xml)); OutputStream out = connection.getOutputStream(); Writer wout = new OutputStreamWriter(out); wout.write(xml); wout.flush(); wout.close(); S result = utf8streamToString(connection.getInputStream()); printIndent(result); /* Using your favourite Java XML Parser, parse the XML output, check that resultCode is equal to 1 and act accordingly */ assertEquals("Voice Synthesis Result", "1", xml_contentsOfTag(result, "resultCode")); S fileUrl = xml_contentsOfTag(result, "fileUrl"); print("URL: " + fileUrl); byte[] data = loadBinaryPage(fileUrl); print("Got " + l(data) + " bytes"); saveBinaryProgramFile("jess.ogg", data); playOgg(byteArrayInputStream(data)); }