import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
class main {
static String getSoundURLVoiceRSS(String text, String voice) {
return "https://api.voicerss.org" + hquery(
"key" , voiceRSS_key(),
"hl" , voice, "src" , text,
"c" , "MP3", "f" , "44khz_16bit_mono");
}
static String hquery(Map params) {
return htmlQuery(params);
}
static String hquery(Object... data) {
return htmlQuery(data);
}
static String voiceRSS_key() {
File f = javaxSecretDir("voicerss-apikey.txt");
return assertNempty("Need " + f2s(f), trim(loadTextFile(f)));
}
static String htmlQuery(Map params) {
return empty(params) ? "" : "?" + makePostData(params);
}
static String htmlQuery(Object... data) {
return empty(data) ? "" : "?" + makePostData(data);
}
static File javaxSecretDir_dir; // can be set to work on different base dir
static File javaxSecretDir() {
return javaxSecretDir_dir != null ? javaxSecretDir_dir : new File(userHome(), "JavaX-Secret");
}
static File javaxSecretDir(String sub) {
return newFile(javaxSecretDir(), sub);
}
static A assertNempty(A a) {
return assertNempty("empty", a);
}
static A assertNempty(String msg, A a) {
if (empty(a)) throw fail(msg + ": " + a);
return a;
}
static String f2s(File f) {
return f == null ? null : f.getAbsolutePath();
}
static String f2s(String s) { return f2s(newFile(s)); }
static String f2s(java.nio.file.Path p) {
return p == null ? null : f2s(p.toFile());
}
static String trim(String s) { return s == null ? null : s.trim(); }
static String trim(StringBuilder buf) { return buf.toString().trim(); }
static String trim(StringBuffer buf) { return buf.toString().trim(); }
static String loadTextFile(String fileName) {
return loadTextFile(fileName, null);
}
static String loadTextFile(File f, String defaultContents) { try {
checkFileNotTooBigToRead(f);
if (f == null || !f.exists()) return defaultContents;
FileInputStream fileInputStream = new FileInputStream(f);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8");
return loadTextFile(inputStreamReader);
} catch (Exception __e) { throw rethrow(__e); } }
public static String loadTextFile(File fileName) {
return loadTextFile(fileName, null);
}
static String loadTextFile(String fileName, String defaultContents) {
return fileName == null ? defaultContents : loadTextFile(newFile(fileName), defaultContents);
}
static String loadTextFile(Reader reader) throws IOException {
StringBuilder builder = new StringBuilder();
try {
char[] buffer = new char[1024];
int n;
while (-1 != (n = reader.read(buffer)))
builder.append(buffer, 0, n);
} finally {
reader.close();
}
return str(builder);
}
static boolean empty(Collection c) { return c == null || c.isEmpty(); }
static boolean empty(CharSequence s) { return s == null || s.length() == 0; }
static boolean empty(Map map) { return map == null || map.isEmpty(); }
static boolean empty(Object[] o) { return o == null || o.length == 0; }
static boolean empty(Object o) {
if (o instanceof Collection) return empty((Collection) o);
if (o instanceof String) return empty((String) o);
if (o instanceof Map) return empty((Map) o);
if (o instanceof Object[]) return empty((Object[]) o);
if (o instanceof byte[]) return empty((byte[]) o);
if (o == null) return true;
throw fail("unknown type for 'empty': " + getType(o));
}
static boolean empty(Iterator i) { return i == null || !i.hasNext(); }
static boolean empty(double[] a) { return a == null || a.length == 0; }
static boolean empty(float[] a) { return a == null || a.length == 0; }
static boolean empty(int[] a) { return a == null || a.length == 0; }
static boolean empty(long[] a) { return a == null || a.length == 0; }
static boolean empty(byte[] a) { return a == null || a.length == 0; }
static boolean empty(short[] a) { return a == null || a.length == 0; }
static boolean empty(File f) { return getFileSize(f) == 0; }
static String makePostData(Map