Create audio module which allows to play sound files

This commit is contained in:
Bartłomiej Pluta
2019-07-09 19:04:55 +02:00
parent b786241f12
commit fc023f8a5d
7 changed files with 49 additions and 1 deletions

17
smnp/audio/sound.py Normal file
View File

@@ -0,0 +1,17 @@
import sounddevice as sd
import soundfile as sf
class Sound:
def __init__(self, file):
self.file = file
self.data, self.fs = sf.read(file, dtype='float32')
def play(self):
sd.play(self.data, self.fs, blocking=True)
def __str__(self):
return f"sound[{self.file}]"
def __repr__(self):
return self.__str__()