Updated static interface
This commit is contained in:
parent
4bf5d980d2
commit
087395e950
@ -93,3 +93,7 @@ class BirbnetesIoTPlatformStatusDriver:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def enqueue_pattern(cls, target: str, pattern: list):
|
def enqueue_pattern(cls, target: str, pattern: list):
|
||||||
cls.blinken_lights.enqueue_pattern(target, pattern)
|
cls.blinken_lights.enqueue_pattern(target, pattern)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def cleanup(cls):
|
||||||
|
cls.blinken_lights.stop()
|
||||||
|
@ -10,3 +10,7 @@ class BirbnetesIoTPlatformPlaybackDriver:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def play_audio(cls, audiofile: str):
|
def play_audio(cls, audiofile: str):
|
||||||
playsound(audiofile)
|
playsound(audiofile)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def cleanup(cls):
|
||||||
|
pass
|
||||||
|
@ -4,6 +4,7 @@ import tempfile
|
|||||||
from queue import Queue, Empty
|
from queue import Queue, Empty
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
import wave
|
import wave
|
||||||
|
import os
|
||||||
|
|
||||||
SAMPLE_RATE = 44100
|
SAMPLE_RATE = 44100
|
||||||
MICROPHONE = 'default'
|
MICROPHONE = 'default'
|
||||||
@ -11,7 +12,6 @@ DEST_FOLDER = "/dev/shm/"
|
|||||||
|
|
||||||
|
|
||||||
class SlicedRecorder(Thread):
|
class SlicedRecorder(Thread):
|
||||||
|
|
||||||
BYTES_PER_SAMPLE = 2 # 16bit
|
BYTES_PER_SAMPLE = 2 # 16bit
|
||||||
|
|
||||||
def __init__(self, slice_size: float, sample_rate=SAMPLE_RATE, microphone=MICROPHONE, dest_folder=DEST_FOLDER):
|
def __init__(self, slice_size: float, sample_rate=SAMPLE_RATE, microphone=MICROPHONE, dest_folder=DEST_FOLDER):
|
||||||
@ -78,11 +78,24 @@ class SlicedRecorder(Thread):
|
|||||||
|
|
||||||
|
|
||||||
class BirbnetesIoTPlatformRecordDriver:
|
class BirbnetesIoTPlatformRecordDriver:
|
||||||
|
sliced_recorder = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def init(cls, sample_length_sec: float):
|
def init(cls, sample_length_sec: float, sample_rate=SAMPLE_RATE, microphone=MICROPHONE, dest_folder=DEST_FOLDER):
|
||||||
pass
|
cls.sliced_recorder = SlicedRecorder(sample_length_sec, sample_rate, microphone, dest_folder)
|
||||||
|
cls.sliced_recorder.start()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_recording(cls, blocking: bool = False):
|
def get_recording(cls, blocking: bool = False) -> Optional[str]:
|
||||||
pass
|
return cls.sliced_recorder.get_recording(blocking)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def cleanup(cls):
|
||||||
|
cls.sliced_recorder.stop()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
fname = cls.sliced_recorder.get_recording(False)
|
||||||
|
if fname:
|
||||||
|
os.unlink(fname)
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user