Skip to content

Commit a991061

Browse files
Merge branch 'dev' of github.com:watson-developer-cloud/java-sdk into dev
2 parents b25ca7f + a8d33a2 commit a991061

File tree

6 files changed

+431
-9
lines changed

6 files changed

+431
-9
lines changed
Lines changed: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
22
* Copyright 2015 IBM Corp. All Rights Reserved.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55
* in compliance with the License. You may obtain a copy of the License at
6-
*
6+
*
77
* http://www.apache.org/licenses/LICENSE-2.0
8-
*
8+
*
99
* Unless required by applicable law or agreed to in writing, software distributed under the License
1010
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
1111
* or implied. See the License for the specific language governing permissions and limitations under
@@ -14,6 +14,9 @@
1414

1515
package com.ibm.watson.developer_cloud.speech_to_text.v1.model;
1616

17+
import java.util.List;
18+
19+
import com.google.gson.annotations.SerializedName;
1720
import com.ibm.watson.developer_cloud.service.model.GenericModel;
1821

1922
/**
@@ -24,9 +27,19 @@ public class SpeechAlternative extends GenericModel {
2427
/** The transcript. */
2528
private String transcript;
2629

30+
/** The confidence. */
31+
private Double confidence;
32+
33+
/** The timestamps. */
34+
private List<SpeechTimestamp> timestamps;
35+
36+
/** The word confidences. */
37+
@SerializedName("word_confidence")
38+
private List<SpeechWordConfidence> wordConfidences;
39+
2740
/**
2841
* Gets the transcript.
29-
*
42+
*
3043
* @return The transcript
3144
*/
3245
public String getTranscript() {
@@ -35,11 +48,87 @@ public String getTranscript() {
3548

3649
/**
3750
* Sets the transcript.
38-
*
51+
*
3952
* @param transcript The transcript
4053
*/
4154
public void setTranscript(final String transcript) {
4255
this.transcript = transcript;
4356
}
4457

58+
/**
59+
* Gets the confidence.
60+
*
61+
* @return The confidence
62+
*/
63+
public Double getConfidence() {
64+
return confidence;
65+
}
66+
67+
/**
68+
* Sets the confidence.
69+
*
70+
* @param confidence The confidence
71+
*/
72+
public void setConfidence(final Double confidence) {
73+
this.confidence = confidence;
74+
}
75+
76+
/**
77+
* Gets the timestamps.
78+
*
79+
* @return The timestamps
80+
*/
81+
public List<SpeechTimestamp> getTimestamps() {
82+
return timestamps;
83+
}
84+
85+
/**
86+
* Sets the timestamps.
87+
*
88+
* @param timestamps The timestamps
89+
*/
90+
public void setTimestamps(final List<SpeechTimestamp> timestamps) {
91+
this.timestamps = timestamps;
92+
}
93+
94+
/**
95+
* With timestamps.
96+
*
97+
* @param timestamps the timestamps
98+
* @return the speech
99+
*/
100+
public SpeechAlternative withTimestamps(final List<SpeechTimestamp> timestamps) {
101+
this.timestamps = timestamps;
102+
return this;
103+
}
104+
105+
106+
/**
107+
* Gets the word confidences.
108+
*
109+
* @return The wordConfidences
110+
*/
111+
public List<SpeechWordConfidence> getWordConfidences() {
112+
return wordConfidences;
113+
}
114+
115+
/**
116+
* Sets the word confidences.
117+
*
118+
* @param wordConfidences The wordConfidences
119+
*/
120+
public void setWordConfidences(final List<SpeechWordConfidence> wordConfidences) {
121+
this.wordConfidences = wordConfidences;
122+
}
123+
124+
/**
125+
* With word confidences.
126+
*
127+
* @param wordConfidences the wordConfidences
128+
* @return the speech
129+
*/
130+
public SpeechAlternative withWordConfidences(final List<SpeechWordConfidence> wordConfidences) {
131+
this.wordConfidences = wordConfidences;
132+
return this;
133+
}
45134
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
package com.ibm.watson.developer_cloud.speech_to_text.v1.model;
16+
17+
import com.google.gson.annotations.JsonAdapter;
18+
import com.ibm.watson.developer_cloud.service.model.GenericModel;
19+
import com.ibm.watson.developer_cloud.speech_to_text.v1.util.SpeechTimestampTypeAdapter;
20+
21+
/**
22+
* The Class SpeechTimestamp.
23+
*/
24+
@JsonAdapter(SpeechTimestampTypeAdapter.class)
25+
public class SpeechTimestamp extends GenericModel {
26+
27+
/** The word. */
28+
private String word;
29+
30+
/** The start time. */
31+
private Double startTime;
32+
33+
/** The end time. */
34+
private Double endTime;
35+
36+
/**
37+
* Gets the word.
38+
*
39+
* @return The word
40+
*/
41+
public String getWord() {
42+
return word;
43+
}
44+
45+
/**
46+
* Sets the word.
47+
*
48+
* @param word The word
49+
*/
50+
public void setWord(final String word) {
51+
this.word = word;
52+
}
53+
54+
/**
55+
* Gets the start time.
56+
*
57+
* @return The start time
58+
*/
59+
public Double getStartTime() {
60+
return startTime;
61+
}
62+
63+
/**
64+
* Sets the start time.
65+
*
66+
* @param startTime The start time
67+
*/
68+
public void setStartTime(final Double startTime) {
69+
this.startTime = startTime;
70+
}
71+
72+
/**
73+
* Gets the end time.
74+
*
75+
* @return The end time
76+
*/
77+
public Double getEndTime() {
78+
return endTime;
79+
}
80+
81+
/**
82+
* Sets the end time.
83+
*
84+
* @param endTime The end time
85+
*/
86+
public void setEndTime(final Double endTime) {
87+
this.endTime = endTime;
88+
}
89+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
15+
package com.ibm.watson.developer_cloud.speech_to_text.v1.model;
16+
17+
import com.google.gson.annotations.JsonAdapter;
18+
import com.ibm.watson.developer_cloud.service.model.GenericModel;
19+
import com.ibm.watson.developer_cloud.speech_to_text.v1.util.SpeechWordConfidenceTypeAdapter;
20+
21+
/**
22+
* The Class SpeechWordConfidence.
23+
*/
24+
@JsonAdapter(SpeechWordConfidenceTypeAdapter.class)
25+
public class SpeechWordConfidence extends GenericModel {
26+
27+
/** The word. */
28+
private String word;
29+
30+
/** The confidence. */
31+
private Double confidence;
32+
33+
/**
34+
* Gets the word.
35+
*
36+
* @return The word
37+
*/
38+
public String getWord() {
39+
return word;
40+
}
41+
42+
/**
43+
* Sets the word.
44+
*
45+
* @param word The word
46+
*/
47+
public void setWord(final String word) {
48+
this.word = word;
49+
}
50+
51+
/**
52+
* Gets the confidence.
53+
*
54+
* @return The confidence
55+
*/
56+
public Double getConfidence() {
57+
return confidence;
58+
}
59+
60+
/**
61+
* Sets the confidence.
62+
*
63+
* @param confidence The confidence
64+
*/
65+
public void setConfidence(final Double confidence) {
66+
this.confidence = confidence;
67+
}
68+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/**
2+
* Copyright 2015 IBM Corp. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*/
14+
package com.ibm.watson.developer_cloud.speech_to_text.v1.util;
15+
16+
import java.io.IOException;
17+
18+
import com.google.gson.TypeAdapter;
19+
import com.google.gson.stream.JsonReader;
20+
import com.google.gson.stream.JsonToken;
21+
import com.google.gson.stream.JsonWriter;
22+
import com.ibm.watson.developer_cloud.speech_to_text.v1.model.SpeechTimestamp;
23+
24+
/**
25+
* SpeechTimestampTypeAdapter
26+
*/
27+
public class SpeechTimestampTypeAdapter extends TypeAdapter<SpeechTimestamp> {
28+
29+
/*
30+
* (non-Javadoc)
31+
*
32+
* @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
33+
*/
34+
@Override
35+
public SpeechTimestamp read(JsonReader reader) throws IOException {
36+
if (reader.peek() == JsonToken.NULL) {
37+
reader.nextNull();
38+
return null;
39+
}
40+
41+
String word = null;
42+
Double startTime = null, endTime = null;
43+
44+
reader.beginArray();
45+
46+
if (reader.peek() == JsonToken.STRING) {
47+
word = reader.nextString();
48+
}
49+
if (reader.peek() == JsonToken.NUMBER) {
50+
startTime = reader.nextDouble();
51+
}
52+
if (reader.peek() == JsonToken.NUMBER) {
53+
endTime = reader.nextDouble();
54+
}
55+
56+
reader.endArray();
57+
58+
SpeechTimestamp speechTimestamp = new SpeechTimestamp();
59+
60+
if (word != null) {
61+
speechTimestamp.setWord(word);
62+
}
63+
64+
if (startTime != null) {
65+
speechTimestamp.setStartTime(startTime);
66+
}
67+
68+
if (endTime != null) {
69+
speechTimestamp.setEndTime(endTime);
70+
}
71+
72+
return speechTimestamp;
73+
}
74+
75+
/*
76+
* (non-Javadoc)
77+
*
78+
* @see com.google.gson.TypeAdapter#write(com.google.gson.stream.JsonWriter, java.lang.Object)
79+
*/
80+
@Override
81+
public void write(JsonWriter writer, SpeechTimestamp speechTimestamp) throws IOException {
82+
writer.beginArray();
83+
84+
writer.value(speechTimestamp.getWord());
85+
writer.value(speechTimestamp.getStartTime());
86+
writer.value(speechTimestamp.getEndTime());
87+
88+
writer.endArray();
89+
writer.flush();
90+
}
91+
}

0 commit comments

Comments
 (0)