1
1
/*******************************************************************************
2
2
* Copyright 2017 CPqD. All Rights Reserved.
3
- *
3
+ *
4
4
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
5
5
* use this file except in compliance with the License. You may obtain a copy
6
6
* of the License at
7
- *
7
+ *
8
8
* http://www.apache.org/licenses/LICENSE-2.0
9
- *
9
+ *
10
10
* Unless required by applicable law or agreed to in writing, software
11
11
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
12
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -33,15 +33,15 @@ public interface SpeechRecognizer {
33
33
34
34
/**
35
35
* Release resources and close the server connection.
36
- *
36
+ *
37
37
* @throws IOException
38
38
* some sort of I/O exception has ocurred.
39
39
*/
40
40
void close () throws IOException ;
41
41
42
42
/**
43
43
* Cancels the current recognition, closing the audio source.
44
- *
44
+ *
45
45
* @throws IOException
46
46
* some sort of I/O exception has ocurred.
47
47
* @throws RecognitionException
@@ -54,12 +54,12 @@ public interface SpeechRecognizer {
54
54
* be created previously. The recognition result will be notified in the
55
55
* registered AsrListener callbacks. The audio source is automatically
56
56
* closed after the end of the recognition process.
57
- *
57
+ *
58
58
* @param lmList
59
59
* the language model to use.
60
60
* @param audio
61
61
* audio source.
62
- *
62
+ *
63
63
* @throws IOException
64
64
* some sort of I/O exception has ocurred.
65
65
* @throws RecognitionException
@@ -72,14 +72,14 @@ public interface SpeechRecognizer {
72
72
* be created previously. The recognition result will be notified in the
73
73
* registered AsrListener callbacks. The audio source is automatically
74
74
* closed after the end of the recognition process.
75
- *
75
+ *
76
76
* @param lmList
77
77
* the language model to use.
78
78
* @param audio
79
79
* audio source.
80
80
* @param config
81
81
* recognition configuration parameters.
82
- *
82
+ *
83
83
* @throws IOException
84
84
* some sort of I/O exception has ocurred.
85
85
* @throws RecognitionException
@@ -92,7 +92,7 @@ void recognize(AudioSource audio, LanguageModelList lmList, RecognitionConfig co
92
92
* Returns the recognition result. If audio packets are still being sent to
93
93
* the server, the method blocks and waits for the end of the recognition
94
94
* process.
95
- *
95
+ *
96
96
* @return the recognition result or null if there is no result available.
97
97
* @throws RecognitionException
98
98
* in case an error in the recognition occurs.
@@ -102,7 +102,7 @@ void recognize(AudioSource audio, LanguageModelList lmList, RecognitionConfig co
102
102
/**
103
103
* Returns the recognition result. If audio packets are still being sent to the
104
104
* server, the method blocks and waits for the end of the recognition process.
105
- *
105
+ *
106
106
* @param timeout
107
107
* the max wait time for a recognition result (in seconds). The timer
108
108
* is started after the last audio packet is sent.
@@ -114,7 +114,7 @@ void recognize(AudioSource audio, LanguageModelList lmList, RecognitionConfig co
114
114
115
115
/**
116
116
* Creates a new instance of the object builder.
117
- *
117
+ *
118
118
* @return the Builder object.
119
119
*/
120
120
static SpeechRecognizer .Builder builder () {
@@ -179,7 +179,7 @@ public class Builder {
179
179
180
180
/**
181
181
* Private constructor. Defines default configuration parameters.
182
- *
182
+ *
183
183
*/
184
184
protected Builder () {
185
185
this .audioSampleRate = 8000 ;
@@ -192,7 +192,7 @@ protected Builder() {
192
192
193
193
/**
194
194
* Builds an SpeechRecognizer instance.
195
- *
195
+ *
196
196
* @return the recognizer instance.
197
197
* @throws URISyntaxException
198
198
* if there is an error with the server URL parameter.
@@ -208,12 +208,13 @@ public SpeechRecognizer build() throws URISyntaxException, IOException, Recognit
208
208
209
209
/**
210
210
* Defines the Server URL.
211
- *
211
+ *
212
212
* @param url
213
213
* the ASR Server endpoint URL (e.g.:
214
214
* ws://192.168.100.1:8025/asr-server).
215
215
* @return the Builder object
216
- * @throws URISyntaxException
216
+ *
217
+ * @throws URISyntaxException Invalid URL
217
218
*/
218
219
public SpeechRecognizer .Builder serverURL (String url ) throws URISyntaxException {
219
220
this .uri = new URI (url );
@@ -222,7 +223,7 @@ public SpeechRecognizer.Builder serverURL(String url) throws URISyntaxException
222
223
223
224
/**
224
225
* Sets user access credentials, if required by the server.
225
- *
226
+ *
226
227
* @param username
227
228
* user id.
228
229
* @param password
@@ -239,7 +240,7 @@ public SpeechRecognizer.Builder credentials(String username, String password) {
239
240
240
241
/**
241
242
* Configure the recognition parameters.
242
- *
243
+ *
243
244
* @param recogConfig
244
245
* the configuration parameters.
245
246
* @return the Builder object.
@@ -251,7 +252,7 @@ public SpeechRecognizer.Builder recogConfig(RecognitionConfig recogConfig) {
251
252
252
253
/**
253
254
* Register a call back listener interface.
254
- *
255
+ *
255
256
* @param listener
256
257
* the listener object.
257
258
* @return the Builder object.
@@ -264,7 +265,7 @@ public SpeechRecognizer.Builder addListener(RecognitionListener listener) {
264
265
/**
265
266
* Sets the user agent data. This information indicates the
266
267
* characteristics of the client for logging and debug purposes.
267
- *
268
+ *
268
269
* @param userAgent
269
270
* the user agent data.
270
271
* @return the Builder object.
@@ -276,7 +277,7 @@ public SpeechRecognizer.Builder userAgent(String userAgent) {
276
277
277
278
/**
278
279
* Sets the maximum time the client waits for the recognition result.
279
- *
280
+ *
280
281
* @param timeout
281
282
* the timeout value (in seconds).
282
283
* @return the Builder object.
@@ -290,7 +291,7 @@ public SpeechRecognizer.Builder maxWaitSeconds(int timeout) {
290
291
* Sets the connect on recognize property. If set to true, the ASR
291
292
* session is automatically created at each recognition. Otherwise, it
292
293
* is created when the SpeechRecognizer is built.
293
- *
294
+ *
294
295
* @param connectOnRecognize
295
296
* the connectOnRecognize property value.
296
297
* @return the Builder object.
@@ -304,7 +305,7 @@ public SpeechRecognizer.Builder connectOnRecognize(boolean connectOnRecognize) {
304
305
* Sets the auto close property. If set to true, the ASR session is
305
306
* automatically closed at the end of each recognition. Otherwise, it is
306
307
* kept open for the next recognition.
307
- *
308
+ *
308
309
* @param autoClose
309
310
* the autoClose property value.
310
311
* @return the Builder object.
@@ -316,7 +317,7 @@ public SpeechRecognizer.Builder autoClose(boolean autoClose) {
316
317
317
318
/**
318
319
* Sets the maximum session idle time.
319
- *
320
+ *
320
321
* @param maxSessionIdleSeconds
321
322
* the max session idle time in seconds.
322
323
* @return the Builder object.
@@ -328,7 +329,7 @@ public SpeechRecognizer.Builder maxSessionIdleSeconds(int maxSessionIdleSeconds)
328
329
329
330
/**
330
331
* Sets the audio sample rate (in bps).
331
- *
332
+ *
332
333
* @param sampleRate
333
334
* the audio sample rate.
334
335
* @return the Builder object.
@@ -341,7 +342,7 @@ private SpeechRecognizer.Builder audioSampleRate(int sampleRate) {
341
342
342
343
/**
343
344
* Sets the audio encoding.
344
- *
345
+ *
345
346
* @param encoding
346
347
* the audio encoding.
347
348
* @return the Builder object.
@@ -354,7 +355,7 @@ private SpeechRecognizer.Builder audioEncoding(AudioEncoding encoding) {
354
355
355
356
/**
356
357
* Sets the audio language.
357
- *
358
+ *
358
359
* @param language
359
360
* the audio language.
360
361
* @return the Builder object.
0 commit comments