Libraryless. Click here for Pure Java version (279L/3K/9K).
1 | !747 |
2 | |
3 | m {
|
4 | //static S text = "This is William"; |
5 | //static S voice = "William"; |
6 | |
7 | static S text = "Jawohl mein Herr"; |
8 | static S voice = "Leopold"; |
9 | |
10 | static S format = "mp3"; // "ogg" |
11 | |
12 | p {
|
13 | S post = "<speakExtended key='p86ffzyal3tvgqfr'><voice>" + htmlencode(voice) + "</voice><text>" + htmlencode(text) + "</text><audioFormat>" + format + "</audioFormat>\n" + |
14 | "</speakExtended>"; |
15 | |
16 | S url = "https://www.cereproc.com/livedemo.php"; |
17 | URL _url = new URL(url); |
18 | URLConnection conn = _url.openConnection(); |
19 | conn.setRequestProperty("Content-Type", "text/plain;charset=UTF-8");
|
20 | conn.setRequestProperty("Accept", "*/*");
|
21 | conn.setRequestProperty("Accept-Encoding", "gzip, deflate");
|
22 | conn.setRequestProperty("Accept-Language", "en-US,en;q=0.8,de;q=0.6");
|
23 | conn.setRequestProperty("Cookie", "has_js=1; Drupal.visitor.liveDemo=p86ffzyal3tvgqfr; _ga=GA1.2.1406621623.1444122980; _gat=1");
|
24 | conn.setRequestProperty("Origin", "https://www.cereproc.com");
|
25 | conn.setRequestProperty("Referer", "https://www.cereproc.com/");
|
26 | 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");
|
27 | |
28 | conn.setDoOutput(true); |
29 | |
30 | OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); |
31 | writer.write(post); |
32 | writer.flush(); |
33 | |
34 | S encoding = conn.getContentEncoding(); |
35 | print("Encoding: " + encoding);
|
36 | |
37 | S contentType = conn.getContentType(); |
38 | print("Content type: " + contentType);
|
39 | |
40 | byte[] response = loadBinaryPage(conn); |
41 | print("Bytes read: " + response.length);
|
42 | |
43 | if ("gzip".equals(encoding))
|
44 | response = gunzipBinaryData(response); |
45 | |
46 | print("Bytes unpacked: " + response.length);
|
47 | S s = new String(response, "UTF-8"); |
48 | print(s); |
49 | |
50 | S oggUrl = null; |
51 | L<S> tok = htmlcoarsetok(s); |
52 | for (int i = 1; i < tok.size(); i += 2) |
53 | if (isTag(tok.get(i), "url")) {
|
54 | oggUrl = tok.get(i+1); |
55 | break; |
56 | } |
57 | if (oggUrl == null) print("No sound URL found");
|
58 | |
59 | byte[] ogg = loadBinaryPage(oggUrl); |
60 | print("Sound bytes: " + ogg.length);
|
61 | |
62 | File outFile = new File(programDir(programID), "bla." + format); |
63 | saveBinaryFile(outFile, ogg); |
64 | print("Saved: " + outFile.getAbsolutePath());
|
65 | } |
66 | } |
Yeah I will buy the app :)
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1001260 |
| Snippet name: | Speech test |
| Eternal ID of this version: | #1001260/1 |
| Text MD5: | ca8e71bc8cf53fb06efa820b93dd2f54 |
| Transpilation MD5: | f1b1e1b9c7f1e359121859d1466571e7 |
| Author: | stefan |
| Category: | |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-10-06 12:14:59 |
| Source code size: | 2421 bytes / 66 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 848 / 936 |
| Referenced in: | [show references] |