use of com.ibm.watson.text_to_speech.v1.model.MarkTiming in project java-sdk by watson-developer-cloud.
the class TextToSpeechIT method testSynthesizeUsingWebSocketWithSsml.
/**
* Test synthesize using web socket with ssml.
*
* @throws InterruptedException the interrupted exception
*/
@Test
public void testSynthesizeUsingWebSocketWithSsml() throws InterruptedException {
List<String> ssmlMarks = new ArrayList<>();
ssmlMarks.add("sean");
ssmlMarks.add("ricky");
String ssmlText = String.format("Thought I'd end up with <mark name=\"%s\" />Sean, <express-as type=\"Apology\"> " + "but he wasn't a match. </express-as> Wrote some songs " + "about <mark name=\"%s\" />Ricky, now I listen and " + "laugh", ssmlMarks.get(0), ssmlMarks.get(1));
SynthesizeOptions synthesizeOptions = new SynthesizeOptions.Builder().text(ssmlText).voice(SynthesizeOptions.Voice.EN_US_ALLISONVOICE).accept(HttpMediaType.AUDIO_OGG).build();
service.synthesizeUsingWebSocket(synthesizeOptions, new BaseSynthesizeCallback() {
@Override
public void onMarks(Marks marks) {
returnedMarks.add(marks);
}
});
// wait for synthesis to complete
lock.await(5, TimeUnit.SECONDS);
for (Marks m : returnedMarks) {
List<MarkTiming> markList = m.getMarks();
for (MarkTiming markTiming : markList) {
assertTrue(ssmlMarks.contains(markTiming.getMark()));
}
}
}
use of com.ibm.watson.text_to_speech.v1.model.MarkTiming in project java-sdk by watson-developer-cloud.
the class MarkTimingTypeAdapter method read.
/*
* (non-Javadoc)
* @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
*/
@Override
public MarkTiming read(JsonReader in) throws IOException {
if (in.peek() == JsonToken.NULL) {
in.nextNull();
return null;
}
final MarkTiming markTiming = new MarkTiming();
in.beginArray();
if (in.peek() == JsonToken.STRING) {
markTiming.setMark(in.nextString());
}
if (in.peek() == JsonToken.NUMBER) {
markTiming.setTime(in.nextDouble());
}
in.endArray();
return markTiming;
}
Aggregations