logo
Browse Source

Support all int types of audio data

Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
Jael Gu 2 years ago
parent
commit
c84eed9100
  1. 6
      vggish.py

6
vggish.py

@ -61,10 +61,8 @@ class Vggish(NNOperator):
def preprocess(self, frames: List[AudioFrame]):
sr = frames[0].sample_rate
audio = numpy.hstack(frames)
if audio.dtype == numpy.int32:
audio = audio / 2147483648.0
elif audio.dtype == numpy.int16:
audio = audio / 32768.0
ii = numpy.iinfo(audio.dtype)
audio = 2 * audio / (ii.max - ii.min + 1)
try:
audio = audio.transpose()
audio_tensors = vggish_input.waveform_to_examples(audio, sr, return_tensor=True)

Loading…
Cancel
Save