case AudioFormat.CODEC_MP3:
case AudioFormat.CODEC_VORBIS:
case AudioFormat.CODEC_AAC:
- return apiFrequency + "_" + bitDepth + "_mono";
+ return apiFrequency + "_" + bitDepth + "bit_mono";
default:
throw new TTSException("Unsupported audio format: " + format);
}
public static final String DEFAULT_VOICE = "default";
+ public static final String API_URL = "https://api.voicerss.org/?key=%s&hl=%s&c=%s&f=%s&src=%s";
+ public static final String API_URL_WITH_VOICE = API_URL + "&v=%s";
+
private final Logger logger = LoggerFactory.getLogger(VoiceRSSCloudImpl.class);
private static final Set<AudioFormat> SUPPORTED_AUDIO_FORMATS = Set.of(
private String createURL(String apiKey, String text, String locale, String voice, String audioCodec,
String audioFormat) {
String encodedMsg = URLEncoder.encode(text, StandardCharsets.UTF_8);
- String url = "http://api.voicerss.org/?key=" + apiKey + "&hl=" + locale + "&c=" + audioCodec + "&f="
- + audioFormat;
+ String url;
if (!DEFAULT_VOICE.equals(voice)) {
- url += "&v=" + voice;
+ url = String.format(API_URL_WITH_VOICE, apiKey, locale, audioCodec, audioFormat, encodedMsg, voice);
+ } else {
+ url = String.format(API_URL, apiKey, locale, audioCodec, audioFormat, encodedMsg);
}
- url += "&src=" + encodedMsg;
return url;
}
}