player.py 文件源码

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

项目:IRLearning_ReSpeaker 作者: Lee-Kevin 项目源码 文件源码
def play_raw(self, raw_data, rate=16000, channels=1, width=2, block=True):
        self.raw = raw_data
        self.width = width
        self.channels = channels
        self.event.clear()
        self.stream = self.pa.open(format=self.pa.get_format_from_width(width),
                                   channels=channels,
                                   rate=rate,
                                   output=True,
                                   # output_device_index=1,
                                   frames_per_buffer=CHUNK_SIZE,
                                   stream_callback=self.raw_callback)
        if block:
            self.event.wait()
            time.sleep(2)             # wait for playing audio data in buffer, a alsa driver bug
            self.stream.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号