Skip to content

Commit fd8a441

Browse files
authored
Merge pull request #57 from twilio/twiml-speech-recognition
Add speech recognition parameters
2 parents a63e775 + 74137ad commit fd8a441

File tree

5 files changed

+136
-47
lines changed

5 files changed

+136
-47
lines changed

src/main/java/com/twilio/twiml/Gather.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,24 @@ public class Gather extends TwiML {
2929
@XmlAttribute
3030
private final String finishOnKey;
3131

32+
@XmlAttribute
33+
private final String partialResultCallback;
34+
35+
@XmlAttribute
36+
private final Method partialResultCallbackMethod;
37+
38+
@XmlAttribute
39+
private final Language language;
40+
41+
@XmlAttribute
42+
private final String hints;
43+
44+
@XmlAttribute
45+
private final Boolean bargeIn;
46+
47+
@XmlAttribute
48+
private final String acknowledgeSoundUrl;
49+
3250
@SuppressWarnings("checkstyle:indentation")
3351
@XmlElements({
3452
@XmlElement(name = "Say", type = Say.class),
@@ -49,6 +67,12 @@ private Gather(Builder b) {
4967
this.method = b.method;
5068
this.finishOnKey = b.finishOnKey;
5169
this.actions = Lists.newArrayList(b.actions);
70+
this.partialResultCallback = b.partialResultCallback;
71+
this.partialResultCallbackMethod = b.partialResultCallbackMethod;
72+
this.language = b.language;
73+
this.hints = b.hints;
74+
this.bargeIn = b.bargeIn;
75+
this.acknowledgeSoundUrl = b.acknowledgeSoundUrl;
5276
}
5377

5478
public Integer getTimeout() {
@@ -75,13 +99,43 @@ public List<TwiML> getActions() {
7599
return actions;
76100
}
77101

102+
public String getPartialResultCallback() {
103+
return partialResultCallback;
104+
}
105+
106+
public Method getPartialResultCallbackMethod() {
107+
return partialResultCallbackMethod;
108+
}
109+
110+
public Language getLanguage() {
111+
return language;
112+
}
113+
114+
public String getHints() {
115+
return hints;
116+
}
117+
118+
public Boolean getBargeIn() {
119+
return bargeIn;
120+
}
121+
122+
public String getAcknowledgeSoundUrl() {
123+
return acknowledgeSoundUrl;
124+
}
125+
78126
public static class Builder {
79127
private Integer timeout;
80128
private Integer numDigits;
81129
private String action;
82130
private Method method;
83131
private String finishOnKey;
84132
private List<TwiML> actions = Lists.newArrayList();
133+
private String partialResultCallback;
134+
private Method partialResultCallbackMethod;
135+
private Language language;
136+
private String hints;
137+
private Boolean bargeIn;
138+
private String acknowledgeSoundUrl;
85139

86140
public Builder timeout(int timeout) {
87141
this.timeout = timeout;
@@ -123,6 +177,36 @@ public Builder pause(Pause pause) {
123177
return this;
124178
}
125179

180+
public Builder partialResultCallback(String partialResultCallback) {
181+
this.partialResultCallback = partialResultCallback;
182+
return this;
183+
}
184+
185+
public Builder partialResultCallbackMethod(Method partialResultCallbackMethod) {
186+
this.partialResultCallbackMethod = partialResultCallbackMethod;
187+
return this;
188+
}
189+
190+
public Builder language(Language language) {
191+
this.language = language;
192+
return this;
193+
}
194+
195+
public Builder hints(String hints) {
196+
this.hints = hints;
197+
return this;
198+
}
199+
200+
public Builder bargeIn(Boolean bargeIn) {
201+
this.bargeIn = bargeIn;
202+
return this;
203+
}
204+
205+
public Builder acknowledgeSoundUrl(String acknowledgeSoundUrl) {
206+
this.acknowledgeSoundUrl = acknowledgeSoundUrl;
207+
return this;
208+
}
209+
126210
public Gather build() {
127211
return new Gather(this);
128212
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package com.twilio.twiml;
2+
3+
/**
4+
* Twilio Languages
5+
*/
6+
public enum Language {
7+
EN("en"),
8+
EN_GB("en-gb"),
9+
EN_AU("en-AU"),
10+
EN_CA("en-GB"),
11+
EN_IN("en-IN"),
12+
EN_US("en-US"),
13+
ES("es"),
14+
ES_ES("es-ES"),
15+
ES_MX("es-MX"),
16+
FR("fr"),
17+
FR_CA("fr-CA"),
18+
FR_FR("fr-FR"),
19+
DE("de"),
20+
DE_DE("de-DE"),
21+
DA_DK("da-DK"),
22+
CA_ES("ca-ES"),
23+
FI_FI("fi-FI"),
24+
IT_IT("it-IT"),
25+
JA_JP("ja-JP"),
26+
KO_KR("ko-KR"),
27+
NB_NO("nb-NO"),
28+
NL_NL("nl-NL"),
29+
PL_PL("pl-PL"),
30+
PT_BR("pt-BR"),
31+
PT_PT("pt-PT"),
32+
RU_RU("ru-RU"),
33+
SV_SE("sv-SE"),
34+
ZH_CN("zh-CN"),
35+
ZH_HK("zh-HK"),
36+
ZH_TW("zh-TW");
37+
38+
private final String value;
39+
40+
Language(String value) {
41+
this.value = value;
42+
}
43+
44+
@Override
45+
public String toString() {
46+
return this.value;
47+
}
48+
}

src/main/java/com/twilio/twiml/Say.java

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,6 @@ public String toString() {
2828
}
2929
}
3030

31-
public enum Language {
32-
EN("en"),
33-
EN_GB("en-gb"),
34-
EN_AU("en-AU"),
35-
EN_CA("en-GB"),
36-
EN_IN("en-IN"),
37-
EN_US("en-US"),
38-
ES("es"),
39-
ES_ES("es-ES"),
40-
ES_MX("es-MX"),
41-
FR("fr"),
42-
FR_CA("fr-CA"),
43-
FR_FR("fr-FR"),
44-
DE("de"),
45-
DE_DE("de-DE"),
46-
DA_DK("da-DK"),
47-
CA_ES("ca-ES"),
48-
FI_FI("fi-FI"),
49-
IT_IT("it-IT"),
50-
JA_JP("ja-JP"),
51-
KO_KR("ko-KR"),
52-
NB_NO("nb-NO"),
53-
NL_NL("nl-NL"),
54-
PL_PL("pl-PL"),
55-
PT_BR("pt-BR"),
56-
PT_PT("pt-PT"),
57-
RU_RU("ru-RU"),
58-
SV_SE("sv-SE"),
59-
ZH_CN("zh-CN"),
60-
ZH_HK("zh-HK"),
61-
ZH_TW("zh-TW");
62-
63-
private final String value;
64-
65-
Language(String value) {
66-
this.value = value;
67-
}
68-
69-
@Override
70-
public String toString() {
71-
return this.value;
72-
}
73-
}
74-
7531
@XmlAttribute
7632
private final Integer loop;
7733

src/test/java/com/twilio/twiml/GatherTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ public void testXml() throws TwiMLException {
1919
.play(new Play.Builder("Hi!").build())
2020
.say(new Say.Builder("Hello world!").build())
2121
.timeout(5)
22+
.hints("Hi there")
2223
.build();
2324

2425
Assert.assertEquals(
25-
"<Gather timeout=\"5\" numDigits=\"4\" action=\"/gather\" method=\"GET\" finishOnKey=\"1\">" +
26+
"<Gather timeout=\"5\" numDigits=\"4\" action=\"/gather\" method=\"GET\" finishOnKey=\"1\" hints=\"Hi there\">" +
2627
"<Pause/>" +
2728
"<Play>Hi!</Play>" +
2829
"<Say>Hello world!</Say>" +

src/test/java/com/twilio/twiml/SayTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class SayTest {
1212
public void testXml() throws TwiMLException {
1313
Say say = new Say.Builder("I <3 Twilio")
1414
.loop(4)
15-
.language(Say.Language.EN_GB)
15+
.language(Language.EN_GB)
1616
.voice(Say.Voice.MAN)
1717
.build();
1818

@@ -23,7 +23,7 @@ public void testXml() throws TwiMLException {
2323
public void testUrl() throws TwiMLException {
2424
Say say = new Say.Builder("I <3 Twilio")
2525
.loop(4)
26-
.language(Say.Language.ES)
26+
.language(Language.ES)
2727
.voice(Say.Voice.ALICE)
2828
.build();
2929

0 commit comments

Comments
 (0)