|
|
@ -115,7 +115,9 @@ class Recorder:
|
|
|
|
mIsMicrophoneBool=None
|
|
|
|
mIsMicrophoneBool=None
|
|
|
|
|
|
|
|
|
|
|
|
mCallbackChunkDef = None
|
|
|
|
mCallbackChunkDef = None
|
|
|
|
|
|
|
|
mCallbackChunkDefThreadList = []
|
|
|
|
mCallbackStopDef = None
|
|
|
|
mCallbackStopDef = None
|
|
|
|
|
|
|
|
mCallbackStopDefThreadList = []
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, inDeviceInt=None):
|
|
|
|
def __init__(self, inDeviceInt=None):
|
|
|
|
"""L-,W+: Инициализация экземпляра класса записи звука
|
|
|
|
"""L-,W+: Инициализация экземпляра класса записи звука
|
|
|
@ -212,16 +214,27 @@ class Recorder:
|
|
|
|
self.mRecordedFramesList.append(self.mStream.read(self.mFramesInt))
|
|
|
|
self.mRecordedFramesList.append(self.mStream.read(self.mFramesInt))
|
|
|
|
self.__TriggerCheck__()
|
|
|
|
self.__TriggerCheck__()
|
|
|
|
|
|
|
|
|
|
|
|
def CaptureWait(self):
|
|
|
|
def CaptureWait(self, inWaitCallbackChunkBool = True, inWaitCallbackStopBool = True):
|
|
|
|
"""L-,W+: Ожидать окончания захвата аудио
|
|
|
|
"""L-,W+: Ожидать окончания захвата аудио. Дополнительно настраивается ожидание окончания всех callback функций.
|
|
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
.. code-block:: python
|
|
|
|
from pyOpenRPA.Robot import Audio
|
|
|
|
from pyOpenRPA.Robot import Audio
|
|
|
|
lRec = Audio.Recorder()
|
|
|
|
lRec = Audio.Recorder()
|
|
|
|
lRec.CaptureStart(inFileNameStr = "out", inFileFormatStr = "mp3", inDurationSecFloat = 10.0, inChunkSecFloat = 5.0)
|
|
|
|
lRec.CaptureStart(inFileNameStr = "out", inFileFormatStr = "mp3", inDurationSecFloat = 10.0, inChunkSecFloat = 5.0)
|
|
|
|
lRec.CaptureWait()
|
|
|
|
lRec.CaptureWait()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param inWaitCallbackChunkBool: True - ожидать выполнение всех асинхронных callback по сохранению части аудиофайла, по умолчанию True
|
|
|
|
|
|
|
|
:type inWaitCallbackChunkBool: bool, опционально
|
|
|
|
|
|
|
|
:param inWaitCallbackStopBool: True - ожидать выполнение всех асинхронных callback по завершению записи, по умолчанию True
|
|
|
|
|
|
|
|
:type inWaitCallbackStopBool: bool, опционально
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
self.mCaptureThread.join()
|
|
|
|
self.mCaptureThread.join()
|
|
|
|
|
|
|
|
if inWaitCallbackChunkBool==True:
|
|
|
|
|
|
|
|
for lItemThread in self.mCallbackChunkDefThreadList:
|
|
|
|
|
|
|
|
if lItemThread.is_alive(): lItemThread.join()
|
|
|
|
|
|
|
|
if inWaitCallbackStopBool==True:
|
|
|
|
|
|
|
|
for lItemThread in self.mCallbackStopDefThreadList:
|
|
|
|
|
|
|
|
if lItemThread.is_alive(): lItemThread.join()
|
|
|
|
|
|
|
|
|
|
|
|
def CaptureStop(self, inWaitStream=True, inExtra=None):
|
|
|
|
def CaptureStop(self, inWaitStream=True, inExtra=None):
|
|
|
|
"""L-,W+: Остановить захват аудио
|
|
|
|
"""L-,W+: Остановить захват аудио
|
|
|
@ -248,6 +261,7 @@ class Recorder:
|
|
|
|
if self.mCallbackStopDef != None:
|
|
|
|
if self.mCallbackStopDef != None:
|
|
|
|
lCallbackThread = threading.Thread(target=self.mCallbackStopDef,args=[self, lFileNameStr], daemon = True)
|
|
|
|
lCallbackThread = threading.Thread(target=self.mCallbackStopDef,args=[self, lFileNameStr], daemon = True)
|
|
|
|
lCallbackThread.start()
|
|
|
|
lCallbackThread.start()
|
|
|
|
|
|
|
|
self.mCallbackStopDefThreadList.append(lCallbackThread)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def CaptureChunk(self, inExtra=None, inForceChunkBool=True, inShiftSecFloat = 0.0):
|
|
|
|
def CaptureChunk(self, inExtra=None, inForceChunkBool=True, inShiftSecFloat = 0.0):
|
|
|
@ -311,6 +325,7 @@ class Recorder:
|
|
|
|
if self.mCallbackChunkDef != None and self.mFileAvailableChunkInt!=None:
|
|
|
|
if self.mCallbackChunkDef != None and self.mFileAvailableChunkInt!=None:
|
|
|
|
lCallbackThread = threading.Thread(target=self.mCallbackChunkDef,args=[self, lFileNameWExtStr], daemon = True)
|
|
|
|
lCallbackThread = threading.Thread(target=self.mCallbackChunkDef,args=[self, lFileNameWExtStr], daemon = True)
|
|
|
|
lCallbackThread.start()
|
|
|
|
lCallbackThread.start()
|
|
|
|
|
|
|
|
self.mCallbackChunkDefThreadList.append(lCallbackThread)
|
|
|
|
self.mStartChunkSecFloat = lTimeSecFloat
|
|
|
|
self.mStartChunkSecFloat = lTimeSecFloat
|
|
|
|
return lFileNameWExtStr
|
|
|
|
return lFileNameWExtStr
|
|
|
|
|
|
|
|
|
|
|
|