Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e047afa

Browse filesBrowse files
authored
Clear the line on the final transcription too (GoogleCloudPlatform#745)
1 parent 352bd05 commit e047afa
Copy full SHA for e047afa

File tree

Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed

‎speech/grpc/transcribe_streaming.py

Copy file name to clipboardExpand all lines: speech/grpc/transcribe_streaming.py
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,18 +182,19 @@ def listen_print_loop(recognize_stream):
182182

183183
# Display interim results, but with a carriage return at the end of the
184184
# line, so subsequent lines will overwrite them.
185-
if not result.is_final:
186-
# If the previous result was longer than this one, we need to print
187-
# some extra spaces to overwrite the previous result
188-
overwrite_chars = ' ' * max(0, num_chars_printed - len(transcript))
185+
#
186+
# If the previous result was longer than this one, we need to print
187+
# some extra spaces to overwrite the previous result
188+
overwrite_chars = ' ' * max(0, num_chars_printed - len(transcript))
189189

190+
if not result.is_final:
190191
sys.stdout.write(transcript + overwrite_chars + '\r')
191192
sys.stdout.flush()
192193

193194
num_chars_printed = len(transcript)
194195

195196
else:
196-
print(transcript)
197+
print(transcript + overwrite_chars)
197198

198199
# Exit recognition if any of the transcribed phrases could be
199200
# one of our keywords.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.