mirror of
https://github.com/rhasspy/espeak-ng.git
synced 2026-11-08 07:32:32 +00:00
TtsService: support detecting SSML documents
This commit is contained in:
@@ -179,8 +179,8 @@ public class SpeechSynthesis {
|
||||
nativeSetPitch(pitch);
|
||||
}
|
||||
|
||||
public void synthesize(String text) {
|
||||
nativeSynthesize(text);
|
||||
public void synthesize(String text, boolean isSsml) {
|
||||
nativeSynthesize(text, isSsml);
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
@@ -257,7 +257,7 @@ public class SpeechSynthesis {
|
||||
|
||||
private native final boolean nativeSetPitch(int pitch);
|
||||
|
||||
private native final boolean nativeSynthesize(String text);
|
||||
private native final boolean nativeSynthesize(String text, boolean isSsml);
|
||||
|
||||
private native final boolean nativeStop();
|
||||
|
||||
|
||||
@@ -192,7 +192,10 @@ public class TtsService extends TextToSpeechService {
|
||||
return;
|
||||
}
|
||||
|
||||
final String text = request.getText();
|
||||
String text = request.getText();
|
||||
if (text == null)
|
||||
return;
|
||||
|
||||
final int gender = getDefaultGender();
|
||||
final int rate = scaleRate(request.getSpeechRate());
|
||||
final int pitch = scalePitch(request.getPitch());
|
||||
@@ -207,6 +210,13 @@ public class TtsService extends TextToSpeechService {
|
||||
}
|
||||
}
|
||||
|
||||
if (text.startsWith("<?xml"))
|
||||
{
|
||||
// eSpeak does not recognise/skip "<?...?>" preprocessing tags,
|
||||
// so need to remove these before passing to synthesize.
|
||||
text = text.substring(text.indexOf("?>") + 2).trim();
|
||||
}
|
||||
|
||||
mCallback = callback;
|
||||
mCallback.start(mEngine.getSampleRate(), mEngine.getAudioFormat(),
|
||||
mEngine.getChannelCount());
|
||||
@@ -214,7 +224,7 @@ public class TtsService extends TextToSpeechService {
|
||||
mEngine.setVoiceByProperties(null, mMatchingVoice.name, gender, 0, 0);
|
||||
mEngine.setRate(rate);
|
||||
mEngine.setPitch(pitch);
|
||||
mEngine.synthesize(text);
|
||||
mEngine.synthesize(text, text.startsWith("<speak"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user