audio.py 文件源码

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

项目:streamtotext 作者: ibm-dev 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号