mirror of
https://www.modelscope.cn/OpenBMB/MiniCPM-o-2_6.git
synced 2025-07-31 01:05:59 +08:00
Release interface in processing
This commit is contained in:
parent
64edf3d723
commit
4f835638ec
@ -102,16 +102,7 @@ class MiniCPMOProcessor(ProcessorMixin):
|
|||||||
|
|
||||||
return MiniCPMOBatchFeature(data={**model_inputs})
|
return MiniCPMOBatchFeature(data={**model_inputs})
|
||||||
|
|
||||||
def audio_feature_extract(
|
def get_audio_placeholder(self, audio_lens, chunk_input, chunk_length):
|
||||||
self,
|
|
||||||
audios: Union[np.ndarray, List[np.ndarray], List[List[np.ndarray]]],
|
|
||||||
audio_parts: Optional[list] = None,
|
|
||||||
chunk_input: Optional[bool] = False,
|
|
||||||
sampling_rate: Optional[int] = None,
|
|
||||||
chunk_length: Optional[int] = 1,
|
|
||||||
**kwargs,
|
|
||||||
):
|
|
||||||
def get_audio_placeholder(audio_lens, chunk_input):
|
|
||||||
pool_step = 2
|
pool_step = 2
|
||||||
feature_lens = math.ceil(audio_lens / self.feature_extractor.hop_length)
|
feature_lens = math.ceil(audio_lens / self.feature_extractor.hop_length)
|
||||||
|
|
||||||
@ -136,6 +127,15 @@ class MiniCPMOProcessor(ProcessorMixin):
|
|||||||
|
|
||||||
return audio_placeholder
|
return audio_placeholder
|
||||||
|
|
||||||
|
def audio_feature_extract(
|
||||||
|
self,
|
||||||
|
audios: Union[np.ndarray, List[np.ndarray], List[List[np.ndarray]]],
|
||||||
|
audio_parts: Optional[list] = None,
|
||||||
|
chunk_input: Optional[bool] = False,
|
||||||
|
sampling_rate: Optional[int] = None,
|
||||||
|
chunk_length: Optional[int] = 1,
|
||||||
|
**kwargs,
|
||||||
|
):
|
||||||
if isinstance(audios, np.ndarray):
|
if isinstance(audios, np.ndarray):
|
||||||
audios_list = [[audios]]
|
audios_list = [[audios]]
|
||||||
elif isinstance(audios[0], np.ndarray):
|
elif isinstance(audios[0], np.ndarray):
|
||||||
@ -156,7 +156,7 @@ class MiniCPMOProcessor(ProcessorMixin):
|
|||||||
# audio placeholder not dependent on audio_parts
|
# audio placeholder not dependent on audio_parts
|
||||||
for audios in audios_list:
|
for audios in audios_list:
|
||||||
if audios:
|
if audios:
|
||||||
audio_ph_list.append([get_audio_placeholder(len(a), chunk_input) for a in audios])
|
audio_ph_list.append([self.get_audio_placeholder(len(a), chunk_input, chunk_length) for a in audios])
|
||||||
else:
|
else:
|
||||||
audio_ph_list.append([])
|
audio_ph_list.append([])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user