Skip to content

Commit

Permalink
[amazonechocontrol]
Browse files Browse the repository at this point in the history
Fix for Announcment Channel
Signed-off-by: Michael Geramb <mail@michael-geramb.at> (github: mgeramb)
  • Loading branch information
Michael Geramb committed Jul 14, 2019
2 parents 35434d9 + 1f352a4 commit 0b9b438
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1441,8 +1441,8 @@ public void sendNotificationToMobileApp(String customerId, String text, @Nullabl
executeSequenceCommand(null, "Alexa.Notifications.SendMobilePush", parameters);
}

public void sendAnnouncement(Device device, String text, @Nullable String bodyText, @Nullable String title,
int ttsVolume, int standardVolume) throws IOException, URISyntaxException {
public void sendAnnouncement(Device device, String text, String bodyText, @Nullable String title, int ttsVolume,
int standardVolume) throws IOException, URISyntaxException {
Map<String, Object> parameters = new HashMap<>();
parameters.put("expireAfter", "PT5S");
JsonAnnouncementContent[] contentArray = new JsonAnnouncementContent[1];
Expand All @@ -1453,6 +1453,9 @@ public void sendAnnouncement(Device device, String text, @Nullable String bodyTe
content.display.title = title;
}
content.display.body = bodyText;
if (text.startsWith("<speak>") && text.endsWith("</speak>")) {
content.speak.type = "ssml";
}
content.speak.value = text;

contentArray[0] = content;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ private void startTextToSpeech(Connection connection, Device device, String text
this.ignoreVolumeChange = scheduler.schedule(this::stopIgnoreVolumeChange, 2000, TimeUnit.MILLISECONDS);
}
if (text.startsWith("<speak>") && text.endsWith("</speak>")) {
String plainText = text.replaceAll("<[^>]+>", "");
connection.sendAnnouncement(device, text, plainText, null, textToSpeechVolume, lastKnownVolume);
String bodyText = text.replaceAll("<[^>]+>", "");
connection.sendAnnouncement(device, text, bodyText, null, textToSpeechVolume, lastKnownVolume);
} else {
connection.textToSpeech(device, text, textToSpeechVolume, lastKnownVolume);
}
Expand Down

0 comments on commit 0b9b438

Please sign in to comment.