add human_handler
This commit is contained in:
parent
ad54248ff3
commit
48d0a7d05d
3
human_handler/__init__.py
Normal file
3
human_handler/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#encoding = utf8
|
||||||
|
|
||||||
|
from .audio_handler import AudioHandler
|
25
human_handler/audio_handler.py
Normal file
25
human_handler/audio_handler.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#encoding = utf8
|
||||||
|
import logging
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class AudioHandler(ABC):
|
||||||
|
def __init__(self, context, handler):
|
||||||
|
self._context = context
|
||||||
|
self._handler = handler
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def on_handle(self, stream, index):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def stop(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def on_next_handle(self, stream, type_):
|
||||||
|
if self._handler is not None:
|
||||||
|
self._handler.on_handle(stream, type_)
|
||||||
|
else:
|
||||||
|
logging.info(f'_handler is None')
|
Loading…
Reference in New Issue
Block a user