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 12 months ago

audio-embedding

Audio Embedding with CLMR

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 2s. This operator is built on top of the original implementation of CLMR. The default model weight provided is pretrained on Magnatagatune Dataset with SampleCNN.


Code Example

Generate embeddings for the audio "test.wav".

Write a pipeline with explicit inputs/outputs name specifications:

from towhee import pipe, ops, DataCollection

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

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


Factory Constructor

Create the operator via the following factory method

audio_embedding.clmr(framework="pytorch")

Parameters:

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 3s.

Returns:

numpy.ndarray

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

Jael Gu b30359f4da Update 22 Commits
file-icon .gitattributes
1.1 KiB
download-icon
Initial commit 2 years ago
file-icon README.md
1.7 KiB
download-icon
Remove dc2 1 year ago
file-icon __init__.py
688 B
download-icon
Refactor 2 years ago
file-icon clmr_checkpoint.py
1.2 KiB
download-icon
Refactor 2 years ago
file-icon clmr_checkpoint_10000.pt
10 MiB
download-icon
Refactor 2 years ago
file-icon clmr_magnatagatune.py
4.7 KiB
download-icon
Update 12 months ago
file-icon clmr_model.py
1.0 KiB
download-icon
Update 2 years ago
file-icon requirements.txt
31 B
download-icon
Replace resampy with torchaudio 2 years ago
file-icon result.png
5.8 KiB
download-icon
Update README 1 year ago
file-icon sample_cnn.py
2.5 KiB
download-icon
Update 2 years ago