Browse Source
Update
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
2 changed files with
3 additions and
2 deletions
-
README.md
-
vggish.py
|
|
@ -21,7 +21,7 @@ audio_encoder = ops.audio_embedding.vggish() |
|
|
|
audio_embedding = audio_encoder("/audio/path/or/url/") |
|
|
|
|
|
|
|
# Audio data as input |
|
|
|
audio_data = np.zeros((441344, 2)) |
|
|
|
audio_data = np.zeros((2, 441344)) |
|
|
|
sample_rate = 44100 |
|
|
|
audio_embedding = audio_encoder(audio_data, sample_rate) |
|
|
|
``` |
|
|
|
|
|
@ -62,6 +62,7 @@ class Vggish(NNOperator): |
|
|
|
audio_tensors = vggish_input.wavfile_to_examples(audio) |
|
|
|
elif isinstance(audio, numpy.ndarray): |
|
|
|
try: |
|
|
|
audio = audio.transpose() |
|
|
|
audio_tensors = vggish_input.waveform_to_examples(audio, sr, return_tensor=True) |
|
|
|
except Exception as e: |
|
|
|
log.error("Fail to load audio data.") |
|
|
@ -77,7 +78,7 @@ class Vggish(NNOperator): |
|
|
|
# # audio_path = '/path/to/audio' |
|
|
|
# # vec = encoder(audio_path) |
|
|
|
# |
|
|
|
# audio_data = numpy.zeros((441344, 2)) |
|
|
|
# audio_data = numpy.zeros((2, 441344)) |
|
|
|
# sample_rate = 44100 |
|
|
|
# vec = encoder(audio_data, sample_rate) |
|
|
|
# print(vec) |
|
|
|