Updated speech2text data layer for interactive inference
@@ -356,6 +356,10 @@ class Speech2TextDataLayer(DataLayer):
audio_length_arr.append(audio_length)
x_id_arr.append(x_id)
max_len = np.max(audio_length_arr)
+ pad_to = self.params.get("pad_to", 8)
+ if pad_to > 0 and self.params.get('backend') == 'librosa':
+ max_len += (pad_to - max_len % pad_to) % pad_to
+
for i, audio in enumerate(audio_arr):
audio = np.pad(
audio, ((0, max_len-len(audio)), (0, 0)),
@@ -422,7 +426,7 @@ class Speech2TextDataLayer(DataLayer):
sample id.
"""
source, audio_duration = get_speech_features(
- wav, 16000., params
+ wav, 16000., self.params
)
return source.astype(self.params['dtype'].as_numpy_dtype()), \
np.int32([len(source)]), np.int32([0]), \
