playsnd.py 文件源码

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

项目:merac-o-matic 作者: RogueAI42 项目源码 文件源码
def play(self, wave):
        self.playing = True
        aud = pyaudio.PyAudio()
        stream = aud.open(format = aud.get_format_from_width(wave.getsampwidth()), channels = wave.getnchannels(), rate = wave.getframerate(), output = True)
        while self.playing:
            data = wave.readframes(1024)
            if not data:
                break
            stream.write(data)
        stream.stop_stream()
        stream.close()
        aud.terminate()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号