logo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readme
Files and versions

Updated 1 year ago

audio-embedding

Audio Embedding with Vggish

Author: Jael Gu


Description

The audio embedding operator converts an input audio into a dense vector which can be used to represent the audio clip's semantics. Each vector represents for an audio clip with a fixed length of around 0.9s. This operator is built on top of VGGish with Pytorch. The model is a VGG variant pre-trained with a large scale of audio dataset AudioSet. As suggested, it is suitable to extract features at high level or warm up a larger model.


Code Example

Generate embeddings for the audio "test.wav".

Write a pipeline with explicit inputs/outputs name specifications:

from towhee.dc2 import pipe, ops, DataCollection

p = (
    pipe.input('path')
        .map('path', 'frame', ops.audio_decode.ffmpeg())
        .map('frame', 'vecs', ops.audio_embedding.vggish())
        .output('path', 'vecs')
)

DataCollection(p('./test.wav')).show()


Factory Constructor

Create the operator via the following factory method

audio_embedding.vggish(weights_path=None, framework="pytorch")

Parameters:

weights_path: str

The path to model weights. If None, it will load default model weights.

framework: str

The framework of model implementation. Default value is "pytorch" since the model is implemented in Pytorch.


Interface

An audio embedding operator generates vectors in numpy.ndarray given towhee audio frames.

Parameters:

data: List[towhee.types.audio_frame.AudioFrame]

Input audio data is a list of towhee audio frames. The input data should represent for an audio longer than 0.9s.

Returns:

numpy.ndarray

Audio embeddings in shape (num_clips, 128). Each embedding stands for features of an audio clip with length of 0.9s.

Jael Gu 3d4ac2528f Add image 30 Commits
file-icon .gitattributes
48 B
download-icon
Refactor 2 years ago
file-icon README.md
2.0 KiB
download-icon
Update README for new pipe 1 year ago
file-icon __init__.py
656 B
download-icon
Revert "update" 2 years ago
file-icon mel_features.py
9.6 KiB
download-icon
Refactor 2 years ago
file-icon requirements.txt
60 B
download-icon
Replace resampy with torchaudio 2 years ago
file-icon result.png
5.9 KiB
download-icon
Add image 1 year ago
file-icon vggish.pth
275 MiB
download-icon
Refactor 2 years ago
file-icon vggish.py
3.4 KiB
download-icon
Replace resampy with torchaudio 2 years ago
file-icon vggish_input.py
3.1 KiB
download-icon
Replace resampy with torchaudio 2 years ago
file-icon vggish_params.py
2.0 KiB
download-icon
Refactor 2 years ago