Ejemplo n.º 1
0
 async def _capture_offline(self, sound_device: str,
                            started_future: asyncio.Future, loop):
     try:
         stream = MicrophoneStreaming(buffersize=self._block_size,
                                      loop=loop)
         async for block, status in stream.generator(started_future):
             try:
                 self._buffer_queue.put_nowait(block)
             except asyncio.QueueFull as fullErr:
                 logger.warning("The audio buffer queue is too full.")
                 raise fullErr
     except MicrophoneCaptureFailed as captureErr:
         logger.error("Unable to capture from {0}", sound_device)
         raise captureErr
     except RuntimeError as rerr:
         logger.error("RuntimeError in capture and transcribe")
         raise rerr
Ejemplo n.º 2
0
async def capture():
    stream = MicrophoneStreaming()
    async for block, status in stream.generator():
        # process data here
        print(len(block))