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