modify handle
This commit is contained in:
parent
74f993bdad
commit
e5bc16133c
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
#encoding = utf8
|
|
||||||
|
|
||||||
from .audio_render import AudioRender
|
|
@ -1,39 +0,0 @@
|
|||||||
#encoding = utf8
|
|
||||||
|
|
||||||
from ctypes import *
|
|
||||||
import os
|
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
current = os.path.dirname(__file__)
|
|
||||||
dynamic_path = os.path.join(current, 'AudioRender.dll')
|
|
||||||
|
|
||||||
|
|
||||||
def audio_render_log_callback(level, log, size):
|
|
||||||
print(f'level={level}, log={log}, len={size}')
|
|
||||||
|
|
||||||
|
|
||||||
class AudioRender:
|
|
||||||
def __init__(self):
|
|
||||||
self.__audio_render_obj = WinDLL(dynamic_path)
|
|
||||||
print(self.__audio_render_obj)
|
|
||||||
if self.__audio_render_obj is not None:
|
|
||||||
CALLBACK_TYPE = CFUNCTYPE(None, c_int, c_ubyte, c_uint)
|
|
||||||
c_callback = CALLBACK_TYPE(audio_render_log_callback)
|
|
||||||
self.__init = self.__audio_render_obj.Initialize(c_callback)
|
|
||||||
print('AudioRender init', self.__init)
|
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
print('AudioRender __del__')
|
|
||||||
if self.__audio_render_obj is None:
|
|
||||||
return
|
|
||||||
if self.__init:
|
|
||||||
self.__audio_render_obj.Uninitialize()
|
|
||||||
|
|
||||||
def write(self, data, size):
|
|
||||||
if not self.__init:
|
|
||||||
return False
|
|
||||||
|
|
||||||
self.__audio_render_obj.argtypes = (POINTER(c_uint8), c_uint)
|
|
||||||
byte_data = np.frombuffer(data, dtype=np.uint8)
|
|
||||||
return self.__audio_render_obj.Write(byte_data.ctypes.data_as(POINTER(c_uint8)), size)
|
|
@ -103,10 +103,10 @@ class AudioInferenceHandler(AudioHandler):
|
|||||||
for i in range(batch_size):
|
for i in range(batch_size):
|
||||||
if not self._is_running:
|
if not self._is_running:
|
||||||
break
|
break
|
||||||
self.on_next_handle((None, mirror_index(length, index),
|
# self.on_next_handle((None, mirror_index(length, index),
|
||||||
# self.on_next_handle((None, human_status.get_index(),
|
self.on_next_handle((None, human_status.get_index(),
|
||||||
audio_frames[i * 2:i * 2 + 2]), 0)
|
audio_frames[i * 2:i * 2 + 2]), 0)
|
||||||
index = index + 1
|
# index = index + 1
|
||||||
else:
|
else:
|
||||||
human_status.start_talking()
|
human_status.start_talking()
|
||||||
logger.info(f'infer======= {current_text}')
|
logger.info(f'infer======= {current_text}')
|
||||||
@ -116,9 +116,9 @@ class AudioInferenceHandler(AudioHandler):
|
|||||||
index_list = []
|
index_list = []
|
||||||
# for i in range(batch_size):
|
# for i in range(batch_size):
|
||||||
for i in range(len(mel_batch)):
|
for i in range(len(mel_batch)):
|
||||||
idx = mirror_index(length, index + i)
|
# idx = mirror_index(length, index + i)
|
||||||
# idx = human_status.get_index()
|
idx = human_status.get_index()
|
||||||
# index_list.append(idx)
|
index_list.append(idx)
|
||||||
face = face_list_cycle[idx]
|
face = face_list_cycle[idx]
|
||||||
img_batch.append(face)
|
img_batch.append(face)
|
||||||
|
|
||||||
@ -152,10 +152,10 @@ class AudioInferenceHandler(AudioHandler):
|
|||||||
if not self._is_running:
|
if not self._is_running:
|
||||||
break
|
break
|
||||||
self.on_next_handle(
|
self.on_next_handle(
|
||||||
(res_frame, mirror_index(length, index), audio_frames[i * 2:i * 2 + 2]),
|
# (res_frame, mirror_index(length, index), audio_frames[i * 2:i * 2 + 2]),
|
||||||
# (res_frame, index_list[i], audio_frames[i * 2:i * 2 + 2]),
|
(res_frame, index_list[i], audio_frames[i * 2:i * 2 + 2]),
|
||||||
0)
|
0)
|
||||||
index = index + 1
|
# index = index + 1
|
||||||
|
|
||||||
logger.info(f'total batch time: {time.perf_counter() - start_time}')
|
logger.info(f'total batch time: {time.perf_counter() - start_time}')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user