[voicerss] Fix bad audio format code and use HTTPS URL instead of HTTP (#12092)
Fix #12091 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
parent
d196dc2c92
commit
e9c9acdbfd
@ -217,7 +217,7 @@ public class VoiceRSSTTSService implements TTSService {
|
|||||||
case AudioFormat.CODEC_MP3:
|
case AudioFormat.CODEC_MP3:
|
||||||
case AudioFormat.CODEC_VORBIS:
|
case AudioFormat.CODEC_VORBIS:
|
||||||
case AudioFormat.CODEC_AAC:
|
case AudioFormat.CODEC_AAC:
|
||||||
return apiFrequency + "_" + bitDepth + "_mono";
|
return apiFrequency + "_" + bitDepth + "bit_mono";
|
||||||
default:
|
default:
|
||||||
throw new TTSException("Unsupported audio format: " + format);
|
throw new TTSException("Unsupported audio format: " + format);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,9 @@ public class VoiceRSSCloudImpl implements VoiceRSSCloudAPI {
|
|||||||
|
|
||||||
public static final String DEFAULT_VOICE = "default";
|
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 final Logger logger = LoggerFactory.getLogger(VoiceRSSCloudImpl.class);
|
||||||
|
|
||||||
private static final Set<AudioFormat> SUPPORTED_AUDIO_FORMATS = Set.of(
|
private static final Set<AudioFormat> SUPPORTED_AUDIO_FORMATS = Set.of(
|
||||||
@ -285,12 +288,12 @@ public class VoiceRSSCloudImpl implements VoiceRSSCloudAPI {
|
|||||||
private String createURL(String apiKey, String text, String locale, String voice, String audioCodec,
|
private String createURL(String apiKey, String text, String locale, String voice, String audioCodec,
|
||||||
String audioFormat) {
|
String audioFormat) {
|
||||||
String encodedMsg = URLEncoder.encode(text, StandardCharsets.UTF_8);
|
String encodedMsg = URLEncoder.encode(text, StandardCharsets.UTF_8);
|
||||||
String url = "http://api.voicerss.org/?key=" + apiKey + "&hl=" + locale + "&c=" + audioCodec + "&f="
|
String url;
|
||||||
+ audioFormat;
|
|
||||||
if (!DEFAULT_VOICE.equals(voice)) {
|
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;
|
return url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user