def play(self):
"""Play audio from source.
This method will block until the source runs out of audio.
"""
p = pyaudio.PyAudio()
stream = p.open(format=p.get_format_from_width(self._width),
channels=self._channels,
rate=self._freq,
output=True)
async with self._source.listen():
async for block in self._source:
async for chunk in block:
stream.write(chunk.audio)
stream.stop_stream()
stream.close()
p.terminate()
评论列表
文章目录