Browse Source
Update README
Signed-off-by: Jael Gu <mengjia.gu@zilliz.com>
main
2 changed files with
16 additions and
3 deletions
-
README.md
-
vggish.py
|
@ -12,10 +12,18 @@ The model is pre-trained with a large scale of audio dataset [AudioSet](https:// |
|
|
As suggested, it is suitable to extract features at high level or warm up a larger model. |
|
|
As suggested, it is suitable to extract features at high level or warm up a larger model. |
|
|
|
|
|
|
|
|
```python |
|
|
```python |
|
|
|
|
|
import numpy as np |
|
|
from towhee import ops |
|
|
from towhee import ops |
|
|
|
|
|
|
|
|
audio_encoder = ops.audio_embedding.vggish() |
|
|
audio_encoder = ops.audio_embedding.vggish() |
|
|
audio_embedding = audio_encoder("/path/to/audio") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Path or url as input |
|
|
|
|
|
audio_embedding = audio_encoder("/audio/path/or/url/") |
|
|
|
|
|
|
|
|
|
|
|
# Audio data as input |
|
|
|
|
|
audio_data = np.zeros((441344, 2)) |
|
|
|
|
|
sample_rate = 44100 |
|
|
|
|
|
audio_embedding = audio_encoder(audio_data, sample_rate) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
## Factory Constructor |
|
|
## Factory Constructor |
|
|
|
@ -71,6 +71,11 @@ class Vggish(NNOperator): |
|
|
|
|
|
|
|
|
# if __name__ == '__main__': |
|
|
# if __name__ == '__main__': |
|
|
# encoder = Vggish() |
|
|
# encoder = Vggish() |
|
|
# audio_path = '/path/to/audio' |
|
|
|
|
|
# vec = encoder(audio_path) |
|
|
|
|
|
|
|
|
# |
|
|
|
|
|
# # audio_path = '/path/to/audio' |
|
|
|
|
|
# # vec = encoder(audio_path) |
|
|
|
|
|
# |
|
|
|
|
|
# audio_data = numpy.zeros((441344, 2)) |
|
|
|
|
|
# sample_rate = 44100 |
|
|
|
|
|
# vec = encoder(audio_data, sample_rate) |
|
|
# print(vec) |
|
|
# print(vec) |
|
|