[英]How do I consume messages that are available right now in a python generator?
I've a audio stream available as a python generator, and a external endpoint that tells if I've to run google speech streaming recognize on the input audio stream. 我有一个可作为python生成器使用的音频流,以及一个外部端点,该端点告诉我是否必须在输入音频流上运行google语音流识别。
Is it possible to consume/destroy all messages until now and proceed to transcribe from this point onwards? 到目前为止,是否可以使用/销毁所有消息并从此开始继续转录? Something like this: 像这样:
while disabled:
time.sleep(30)
for _ in stream:
pass
disabled = check_endpoint()
streaming_transcribe(stream)
You can generally handle this with a loop on the generator results: 您通常可以在生成器结果上循环处理:
for message in streaming_transcribe(stream):
# Process message
pass
if check_endpoint(): break
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.