Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions speech/api/speech_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def make_channel(host, port):
return implementations.secure_channel(host, port, composite_channel)


# [START audio_stream]
@contextlib.contextmanager
def record_audio(channels, rate, chunk):
"""Opens a recording stream in a context manager."""
Expand All @@ -70,6 +71,7 @@ def record_audio(channels, rate, chunk):
audio_stream.stop_stream()
audio_stream.close()
audio_interface.terminate()
# [END audio_stream]


def request_stream(stop_audio, channels=CHANNELS, rate=RATE, chunk=CHUNK):
Expand Down