Skip to content

Commit 32030e4

Browse files
maxnussbaumGERMAN ATTANASIO RUIZ
authored andcommitted
refactor(websocket): Adjust websocket logic statement
1 parent accc5ab commit 32030e4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/watson_apis/websocket/speech_to_text_websocket_listener.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,12 @@ def send_audio(data:)
117117
if @chunk_data
118118
if @mic_running
119119
@queue.empty? ? send_chunk(chunk: nil, final: false) : send_chunk(chunk: @queue.pop(true), final: false)
120+
elsif @queue.length == 1
121+
send_chunk(chunk: @queue.pop(true), final: true)
122+
@queue.close
123+
@timer.cancel if @timer.respond_to?(:cancel)
124+
return
120125
else
121-
if @queue.length == 1
122-
send_chunk(chunk: @queue.pop(true), final: true)
123-
@queue.close
124-
@timer.cancel if @timer.respond_to?(:cancel)
125-
return
126-
end
127126
send_chunk(chunk: @queue.pop(true), final: false) unless @queue.empty?
128127
end
129128
else

0 commit comments

Comments
 (0)