1 | sS getSoundURLCereproc(S text, S voice) { |
2 | ret getSoundURLCereproc_raw(htmlencode(text), voice); |
3 | } |
4 | |
5 | static S getSoundURLCereproc_raw(S text, S voice) ctex { |
6 | S format = "mp3"; |
7 | |
8 | S post = "<speakExtended key='2k4fhzwgr8eka9k9'><voice>" + htmlencode(voice) + "</voice><text>" + text + "</text><audioFormat>" + format + "</audioFormat>\n" + |
9 | "</speakExtended>"; |
10 | |
11 | S url = "https://www.cereproc.com/livedemo.php"; |
12 | URL _url = new URL(url); |
13 | URLConnection conn = _url.openConnection(); |
14 | conn.setRequestProperty("Content-Type", "text/plain;charset=UTF-8"); |
15 | conn.setRequestProperty("Accept", "*/*"); |
16 | conn.setRequestProperty("Accept-Encoding", "gzip, deflate"); |
17 | conn.setRequestProperty("Accept-Language", "en-US,en;q=0.8,de;q=0.6"); |
18 | conn.setRequestProperty("Cookie", "has_js=1; _ga=GA1.2.1903717829.1455235694; Drupal.visitor.liveDemo=2k4fhzwgr8eka9k9"); |
19 | conn.setRequestProperty("Origin", "https://www.cereproc.com"); |
20 | conn.setRequestProperty("Referer", "https://www.cereproc.com/"); |
21 | 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"); |
22 | |
23 | conn.setDoOutput(true); |
24 | |
25 | //OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream()); |
26 | OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream(), "UTF-8"); |
27 | writer.write(post); |
28 | writer.flush(); |
29 | |
30 | S encoding = conn.getContentEncoding(); |
31 | //print("Encoding: " + encoding); |
32 | |
33 | S contentType = conn.getContentType(); |
34 | //print("Content type: " + contentType); |
35 | |
36 | byte[] response = loadBinaryPage(conn); |
37 | //print("Bytes read: " + response.length); |
38 | |
39 | if ("gzip".equals(encoding)) |
40 | response = gunzipBinaryData(response); |
41 | |
42 | //print("Bytes unpacked: " + response.length); |
43 | S s = new String(response, "UTF-8"); |
44 | //print(s); |
45 | |
46 | S oggUrl = null; |
47 | L<S> tok = htmlcoarsetok(s); |
48 | for (int i = 1; i < tok.size(); i += 2) |
49 | if (isTag(tok.get(i), "url")) { |
50 | oggUrl = tok.get(i+1); |
51 | break; |
52 | } |
53 | if (oggUrl == null) fail("No sound URL found"); |
54 | ret oggUrl; |
55 | } |
Began life as a copy of #1001273 Huh. What is the relation of this to makeSpeechCereproc?
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002670 |
Snippet name: | getSoundURLCereproc |
Eternal ID of this version: | #1002670/2 |
Text MD5: | abff7090a3553626ca427b4c8ec241fe |
Author: | stefan |
Category: | |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-08-25 20:51:32 |
Source code size: | 2150 bytes / 55 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 695 / 649 |
Version history: | 1 change(s) |
Referenced in: | [show references] |