网站制作定制,毕业做网站运营好吗,智能建造的发展趋势,哈尔滨网站开发方案我想添加一个错误处理程序#xff0c;它可以在出现internet连接问题时停止转录过程。我创建了一个连接监视器线程#xff0c;每隔几秒钟检查一次internet连接#xff0c;并将设置一个标志isConnectionError True。在我设法停止音频录制生成器进程#xff0c;但无法停止另一…我想添加一个错误处理程序它可以在出现internet连接问题时停止转录过程。我创建了一个连接监视器线程每隔几秒钟检查一次internet连接并将设置一个标志isConnectionError True。在我设法停止音频录制生成器进程但无法停止另一个阻止并等待服务器发送响应消息的生成器进程def listen_print_loop(responses):Iterates through server responses and prints them.The responses passed is a generator that will block until a responseis provided by the server.Each response may contain multiple results, and each result may containmultiple alternatives; for details, see . Here weprint only the transcription for the top alternative of the top result.In this case, responses are provided for interim results as well. If theresponse is an interim one, print a line feed at the end of it, to allowthe next result to overwrite it, until the response is a final one. For thefinal one, print a newline to preserve the finalized transcription.num_chars_printed 0for response in responses:if not response.results:continue# The results list is consecutive. For streaming, we only care about# the first result being considered, since once its is_final, it# moves on to considering the next utterance.result response.results[0]if not result.alternatives:continue# Display the transcription of the top alternative.transcript result.alternatives[0].transcript# Display interim results, but with a carriage return at the end of the# line, so subsequent lines will overwrite them.## If the previous result was longer than this one, we need to print# some extra spaces to overwrite the previous resultoverwrite_chars * (num_chars_printed - len(transcript))if not result.is_final:sys.stdout.write(transcript overwrite_chars \r)sys.stdout.flush()num_chars_printed len(transcript)else:print(transcript overwrite_chars)# Exit recognition if any of the transcribed phrases could be# one of our keywords.if re.search(r\b(exit|quit)\b, transcript, re.I):print(Exiting..)breaknum_chars_printed 0