Skip to content

Commit 66f1090

Browse files
committed
Fix: encoding for examples and javadoc
1 parent 1fca446 commit 66f1090

File tree

3 files changed

+49
-43
lines changed

3 files changed

+49
-43
lines changed

recognizer-examples/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<properties>
1515
<maven.compiler.source>1.8</maven.compiler.source>
1616
<maven.compiler.target>1.8</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1718
</properties>
18-
1919
<dependencies>
2020
<dependency>
2121
<groupId>br.com.cpqd.asr</groupId>

recognizer/src/main/java/br/com/cpqd/asr/recognizer/SpeechRecognizer.java

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*******************************************************************************
22
* Copyright 2017 CPqD. All Rights Reserved.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
* use this file except in compliance with the License. You may obtain a copy
66
* of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
1212
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -33,15 +33,15 @@ public interface SpeechRecognizer {
3333

3434
/**
3535
* Release resources and close the server connection.
36-
*
36+
*
3737
* @throws IOException
3838
* some sort of I/O exception has ocurred.
3939
*/
4040
void close() throws IOException;
4141

4242
/**
4343
* Cancels the current recognition, closing the audio source.
44-
*
44+
*
4545
* @throws IOException
4646
* some sort of I/O exception has ocurred.
4747
* @throws RecognitionException
@@ -54,12 +54,12 @@ public interface SpeechRecognizer {
5454
* be created previously. The recognition result will be notified in the
5555
* registered AsrListener callbacks. The audio source is automatically
5656
* closed after the end of the recognition process.
57-
*
57+
*
5858
* @param lmList
5959
* the language model to use.
6060
* @param audio
6161
* audio source.
62-
*
62+
*
6363
* @throws IOException
6464
* some sort of I/O exception has ocurred.
6565
* @throws RecognitionException
@@ -72,14 +72,14 @@ public interface SpeechRecognizer {
7272
* be created previously. The recognition result will be notified in the
7373
* registered AsrListener callbacks. The audio source is automatically
7474
* closed after the end of the recognition process.
75-
*
75+
*
7676
* @param lmList
7777
* the language model to use.
7878
* @param audio
7979
* audio source.
8080
* @param config
8181
* recognition configuration parameters.
82-
*
82+
*
8383
* @throws IOException
8484
* some sort of I/O exception has ocurred.
8585
* @throws RecognitionException
@@ -92,7 +92,7 @@ void recognize(AudioSource audio, LanguageModelList lmList, RecognitionConfig co
9292
* Returns the recognition result. If audio packets are still being sent to
9393
* the server, the method blocks and waits for the end of the recognition
9494
* process.
95-
*
95+
*
9696
* @return the recognition result or null if there is no result available.
9797
* @throws RecognitionException
9898
* in case an error in the recognition occurs.
@@ -102,7 +102,7 @@ void recognize(AudioSource audio, LanguageModelList lmList, RecognitionConfig co
102102
/**
103103
* Returns the recognition result. If audio packets are still being sent to the
104104
* server, the method blocks and waits for the end of the recognition process.
105-
*
105+
*
106106
* @param timeout
107107
* the max wait time for a recognition result (in seconds). The timer
108108
* is started after the last audio packet is sent.
@@ -114,7 +114,7 @@ void recognize(AudioSource audio, LanguageModelList lmList, RecognitionConfig co
114114

115115
/**
116116
* Creates a new instance of the object builder.
117-
*
117+
*
118118
* @return the Builder object.
119119
*/
120120
static SpeechRecognizer.Builder builder() {
@@ -179,7 +179,7 @@ public class Builder {
179179

180180
/**
181181
* Private constructor. Defines default configuration parameters.
182-
*
182+
*
183183
*/
184184
protected Builder() {
185185
this.audioSampleRate = 8000;
@@ -192,7 +192,7 @@ protected Builder() {
192192

193193
/**
194194
* Builds an SpeechRecognizer instance.
195-
*
195+
*
196196
* @return the recognizer instance.
197197
* @throws URISyntaxException
198198
* if there is an error with the server URL parameter.
@@ -208,12 +208,13 @@ public SpeechRecognizer build() throws URISyntaxException, IOException, Recognit
208208

209209
/**
210210
* Defines the Server URL.
211-
*
211+
*
212212
* @param url
213213
* the ASR Server endpoint URL (e.g.:
214214
* ws://192.168.100.1:8025/asr-server).
215215
* @return the Builder object
216-
* @throws URISyntaxException
216+
*
217+
* @throws URISyntaxException Invalid URL
217218
*/
218219
public SpeechRecognizer.Builder serverURL(String url) throws URISyntaxException {
219220
this.uri = new URI(url);
@@ -222,7 +223,7 @@ public SpeechRecognizer.Builder serverURL(String url) throws URISyntaxException
222223

223224
/**
224225
* Sets user access credentials, if required by the server.
225-
*
226+
*
226227
* @param username
227228
* user id.
228229
* @param password
@@ -239,7 +240,7 @@ public SpeechRecognizer.Builder credentials(String username, String password) {
239240

240241
/**
241242
* Configure the recognition parameters.
242-
*
243+
*
243244
* @param recogConfig
244245
* the configuration parameters.
245246
* @return the Builder object.
@@ -251,7 +252,7 @@ public SpeechRecognizer.Builder recogConfig(RecognitionConfig recogConfig) {
251252

252253
/**
253254
* Register a call back listener interface.
254-
*
255+
*
255256
* @param listener
256257
* the listener object.
257258
* @return the Builder object.
@@ -264,7 +265,7 @@ public SpeechRecognizer.Builder addListener(RecognitionListener listener) {
264265
/**
265266
* Sets the user agent data. This information indicates the
266267
* characteristics of the client for logging and debug purposes.
267-
*
268+
*
268269
* @param userAgent
269270
* the user agent data.
270271
* @return the Builder object.
@@ -276,7 +277,7 @@ public SpeechRecognizer.Builder userAgent(String userAgent) {
276277

277278
/**
278279
* Sets the maximum time the client waits for the recognition result.
279-
*
280+
*
280281
* @param timeout
281282
* the timeout value (in seconds).
282283
* @return the Builder object.
@@ -290,7 +291,7 @@ public SpeechRecognizer.Builder maxWaitSeconds(int timeout) {
290291
* Sets the connect on recognize property. If set to true, the ASR
291292
* session is automatically created at each recognition. Otherwise, it
292293
* is created when the SpeechRecognizer is built.
293-
*
294+
*
294295
* @param connectOnRecognize
295296
* the connectOnRecognize property value.
296297
* @return the Builder object.
@@ -304,7 +305,7 @@ public SpeechRecognizer.Builder connectOnRecognize(boolean connectOnRecognize) {
304305
* Sets the auto close property. If set to true, the ASR session is
305306
* automatically closed at the end of each recognition. Otherwise, it is
306307
* kept open for the next recognition.
307-
*
308+
*
308309
* @param autoClose
309310
* the autoClose property value.
310311
* @return the Builder object.
@@ -316,7 +317,7 @@ public SpeechRecognizer.Builder autoClose(boolean autoClose) {
316317

317318
/**
318319
* Sets the maximum session idle time.
319-
*
320+
*
320321
* @param maxSessionIdleSeconds
321322
* the max session idle time in seconds.
322323
* @return the Builder object.
@@ -328,7 +329,7 @@ public SpeechRecognizer.Builder maxSessionIdleSeconds(int maxSessionIdleSeconds)
328329

329330
/**
330331
* Sets the audio sample rate (in bps).
331-
*
332+
*
332333
* @param sampleRate
333334
* the audio sample rate.
334335
* @return the Builder object.
@@ -341,7 +342,7 @@ private SpeechRecognizer.Builder audioSampleRate(int sampleRate) {
341342

342343
/**
343344
* Sets the audio encoding.
344-
*
345+
*
345346
* @param encoding
346347
* the audio encoding.
347348
* @return the Builder object.
@@ -354,7 +355,7 @@ private SpeechRecognizer.Builder audioEncoding(AudioEncoding encoding) {
354355

355356
/**
356357
* Sets the audio language.
357-
*
358+
*
358359
* @param language
359360
* the audio language.
360361
* @return the Builder object.

recognizer/src/main/java/br/com/cpqd/asr/recognizer/ws/AsrClientEndpoint.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/*******************************************************************************
22
* Copyright 2018 CPqD. All Rights Reserved.
3-
*
3+
*
44
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
55
* use this file except in compliance with the License. You may obtain a copy
66
* of the License at
7-
*
7+
*
88
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
9+
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
1212
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -73,7 +73,7 @@
7373

7474
/**
7575
* Websocket endpoint (JSR 356) for communicating with the ASR server.
76-
*
76+
*
7777
*/
7878
@ClientEndpoint(decoders = { AsrProtocolEncoder.class }, encoders = { AsrProtocolEncoder.class })
7979
public class AsrClientEndpoint {
@@ -102,9 +102,14 @@ public class AsrClientEndpoint {
102102

103103
/**
104104
* Constructor.
105-
*
105+
*
106106
* @param uri
107107
* the websocket server endpoint URI.
108+
* @param username
109+
* Username to have access to API.
110+
* @param password
111+
* Password to have access to API.
112+
*
108113
* @throws URISyntaxException
109114
* invalid server URL (e.g: 'ws://127.0.0.1:8025/asr-server/asr').
110115
*/
@@ -161,7 +166,7 @@ public AsrClientEndpoint(URI uri, String username, String password) throws URISy
161166

162167
/**
163168
* Opens a websocket connection with the server.
164-
*
169+
*
165170
* @throws IOException
166171
* some sort of I/O exception has ocurred.
167172
* @throws DeploymentException
@@ -174,7 +179,7 @@ public void open() throws DeploymentException, IOException {
174179

175180
/**
176181
* Returns the registered listeners for protocol events.
177-
*
182+
*
178183
* @return the registered listeners.
179184
*/
180185
public List<RecognitionListener> getListeners() {
@@ -183,7 +188,7 @@ public List<RecognitionListener> getListeners() {
183188

184189
/**
185190
* Verifies if the server connection is open.
186-
*
191+
*
187192
* @return true if the connection is open.
188193
*/
189194
public boolean isOpen() {
@@ -211,7 +216,7 @@ public void close() {
211216
/**
212217
* Send a binary message to the server, via websocket connection, and wait for
213218
* the server response.
214-
*
219+
*
215220
* @param message
216221
* the protocol message object.
217222
* @return the response message.
@@ -233,7 +238,7 @@ public synchronized ResponseMessage sendMessageAndWait(AsrMessage message) throw
233238

234239
/**
235240
* Send a binary message to the server, via websocket connection.
236-
*
241+
*
237242
* @param message
238243
* the protocol message object.
239244
* @throws IOException
@@ -247,7 +252,7 @@ public synchronized void sendMessage(AsrMessage message) throws IOException, Enc
247252

248253
/**
249254
* Call back method called when the websocket connection is opened.
250-
*
255+
*
251256
* @param session
252257
* the websocket session.
253258
*/
@@ -259,7 +264,7 @@ public void onOpen(Session session) {
259264

260265
/**
261266
* Call back method called when the websocket connection is closed.
262-
*
267+
*
263268
* @param session
264269
* the websocket session.
265270
* @param closeReason
@@ -295,7 +300,7 @@ public void onClose(Session session, CloseReason closeReason) {
295300

296301
/**
297302
* Call back method called when a protocol message is received.
298-
*
303+
*
299304
* @param message
300305
* the protocol message.
301306
* @param session
@@ -445,7 +450,7 @@ public void onError(Session session, Throwable thr) {
445450

446451
/**
447452
* Returns the websocket session id.
448-
*
453+
*
449454
* @return the websocket session id.
450455
*/
451456
public String getSessionId() {
@@ -457,7 +462,7 @@ public String getSessionId() {
457462

458463
/**
459464
* Returns the recognition session status.
460-
*
465+
*
461466
* @return the recognition session status.
462467
*/
463468
public SessionStatus getStatus() {

0 commit comments

Comments
 (0)