GeezerVison is showing github.com — STT: Use 1kb for web sockets frames · semtle/java-sdk@9c57fec
File tree
Expand file treeCollapse file tree
Open diff view settings
speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: speech-to-text/src/main/java/com/ibm/watson/developer_cloud/speech_to_text/v1/websocket/SpeechToTextWebSocketListener.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,7 +49,7 @@ public final class SpeechToTextWebSocketListener extends WebSocketListener { |
49 | 49 | private static final String START = "start"; |
50 | 50 | private static final String STOP = "stop"; |
51 | 51 | private static final String ACTION = "action"; |
52 | | - private static final int FOUR_KB = 4096; |
| 52 | + private static final int ONE_KB = 1024; |
53 | 53 | private static final String ERROR = "error"; |
54 | 54 | private static final String RESULTS = "results"; |
55 | 55 | private static final String SPEAKER_LABELS = "speaker_labels"; |
@@ -182,14 +182,14 @@ public void run() { |
182 | 182 | * @param inputStream the input stream |
183 | 183 | */ |
184 | 184 | private void sendInputStream(InputStream inputStream) { |
185 | | - byte[] buffer = new byte[FOUR_KB]; |
| 185 | + byte[] buffer = new byte[ONE_KB]; |
186 | 186 | int read; |
187 | 187 | try { |
188 | 188 | // This method uses a blocking while loop to receive all contents of the underlying input stream. |
189 | 189 | // AudioInputStreams, typically used for streaming microphone inputs return 0 only when the stream has been |
190 | 190 | // closed. Elsewise AudioInputStream.read() blocks until enough audio frames are read. |
191 | 191 | while (((read = inputStream.read(buffer)) > 0) && socketOpen) { |
192 | | - if (read == FOUR_KB) { |
| 192 | + if (read == ONE_KB) { |
193 | 193 | socket.send(ByteString.of(buffer)); |
194 | 194 | } else { |
195 | 195 | socket.send(ByteString.of(Arrays.copyOfRange(buffer, 0, read))); |
|