Uses 74K of libraries. Click here for Pure Java version (1795L/12K/42K).
!7 p { // Try coughing //S text = [[<spurt audio="g0001_004">cough</spurt> I can now cough]]; S text = [[<spurt audio="g0001_028">cough</spurt>]]; //S text = [[Today, <voice emotion='happy'>the sun is shining.</voice>]]; //S text = [[When people leave a tip they want to know it will //<voice emotion='cross'> not be used</voice> to make up the minimum wage.]]; File credentialsFile = newFile(javaxSecretDir(), "cereproc.txt"); L<S> secret = tlft(credentialsFile); assertEquals("Please give me " + f2s(credentialsFile), 2, l(secret)); String xml = "<?xml version='1.0'?><speakSimple>" +"<accountID>" + first(secret) + "</accountID>" +"<password>" + second(secret) + "</password>" +"<voice>Jess</voice>" +"<text>" + text + "</text></speakSimple>"; 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)); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, wtqryiryparv
No comments. add comment
| Snippet ID: | #1009233 |
| Snippet name: | CereProc Cloud Test [WORKS] |
| Eternal ID of this version: | #1009233/23 |
| Text MD5: | 2a2004aeb6348ae0338b4ab795645b55 |
| Transpilation MD5: | 6b37ed250db0283d95fb0c22da8d0230 |
| Author: | stefan |
| Category: | javax / tts |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-07-25 17:57:53 |
| Source code size: | 1979 bytes / 51 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 831 / 993 |
| Version history: | 22 change(s) |
| Referenced in: | -