transcribe_streaming.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:hackfair-speech 作者: DjangoGirlsSeoul 项目源码 文件源码
def _audio_data_generator(buff):
    """A generator that yields all available data in the given buffer.
    Args:
        buff - a Queue object, where each element is a chunk of data.
    Yields:
        A chunk of data that is the aggregate of all chunks of data in `buff`.
        The function will block until at least one data chunk is available.
    """
    while True:
        # Use a blocking get() to ensure there's at least one chunk of data
        chunk = buff.get()
        if not chunk:
            # A falsey value indicates the stream is closed.
            break
        data = [chunk]

        # Now consume whatever other data's still buffered.
        while True:
            try:
                data.append(buff.get(block=False))
            except queue.Empty:
                break
        yield b''.join(data)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号