def __init__(self,waveFile,chunkSize=480,simulate=True,vaDetector=None,oKey="data",name=None): ''' Args: _waveFile_: (str) A wave file path. _chunkSize_: (int) How many sampling points of each reading. _simulate_: (bool) If True, simulate actual clock. _vaDetector_: (VADetector) A VADetector object to detect the stream. _name_: (str) Name. ''' super().__init__(oKey=oKey,name=name) # Config audio information self.__audio_info = self.__direct_source(waveFile) # If simulate is True, simulate real-time reading. assert isinstance(simulate,bool), f"{self.name}: <simulate> should be a bool value." self.__simulate = simulate # Config chunk size assert isinstance(chunkSize,int) and chunkSize > 0 self.__points = chunkSize # Config VAD self.__vad = None if vaDetector is not None: assert isinstance(vaDetector,VADetector), f"{self.name}: <vaDetector> should be a VADetector object." if isinstance(vaDetector,WebrtcVADetector): assert self.__points in [160,320,480], f"{self.name}: If use webrtcvad, please set the chunk size: 160, 320,or 480." self.__vad = vaDetector # A flag for time sleep self.__timeSpan = self.__points/self.__rate # A flag to set sampling id self.__id_counter = 0 # self.link( NullPIPE() )
def __init__(self,chunkSize=480,vaDetector=None,oKey="data",name=None): ''' Args: _waveFile_: (str) A wave file path. _chunkSize_: (int) How many sampling points of each reading. _simulate_: (bool) If True, simulate actual clock. _vaDetector_: (VADetector) A VADetector object to detect the stream. _name_: (str) Name. ''' super().__init__(oKey=oKey,name=name) # Config chunk size assert isinstance(chunkSize,int) and chunkSize > 0 self.__points = chunkSize # Config VAD self.__vad = None if vaDetector is not None: assert isinstance(vaDetector,VADetector), f"{self.name}: <vaDetector> should be a VADetector object." if isinstance(vaDetector,WebrtcVADetector): assert self.__points in [160,320,480], f"{self.name}: If use webrtcvad, please set the chunk size: 160, 320,or 480." self.__vad = vaDetector # Config audio information self.__audio_info = self.__config_format(Rate=16000,Channels=1,Width=2) # A flag to set sampling id self.__id_counter = 0 # self.link( NullPIPE() )
def __init__(self, bport=9509, name=None): ''' Args: _bport_: (int) Bind port ID. _name_: (str) name. ''' super().__init__(oKey="null", name=name) # Define the protocol self.__bport = bport # self.link(NullPIPE())
def start(self,inPIPE=None,iKey=None): if inPIPE is None and self.inPIPE is None: inPIPE = NullPIPE() super().start( inPIPE=inPIPE )
def link(self,inPIPE=None,iKey=None): if inPIPE is None: inPIPE = NullPIPE() super().link( inPIPE=inPIPE )