diff --git a/README.md b/README.md index d2a9f9d..d962f16 100644 --- a/README.md +++ b/README.md @@ -18,37 +18,22 @@ This operator extracts features for audio with [data2vec](https://arxiv.org/abs/ Generate embeddings for the audio "test.wav". - - *Write the pipeline in simplified style*: +*Write a pipeline with explicit inputs/outputs name specifications:* ```python -import towhee - -( - towhee.glob('test.wav') - .audio_decode.ffmpeg() - .runas_op(func=lambda x:[y[0] for y in x]) - .audio_embedding.data2vec() - .show() -) - -``` +from towhee.dc2 import pipe, ops, DataCollection -*Write a same pipeline with explicit inputs/outputs name specifications:* - -```python -import towhee - -( - towhee.glob['path']('test.wav') - .audio_decode.ffmpeg['path', 'frames']() - .runas_op['frames', 'frames'](func=lambda x:[y[0] for y in x]) - .audio_embedding.data2vec['frames', 'vecs'](model_name="facebook/data2vec-audio-base-960h") - .select['path', 'vecs']() - .show() +p = ( + pipe.input('path') + .map('path', 'frame', ops.audio_decode.ffmpeg(sample_rate=16000)) + .map('frame', 'vecs', ops.audio_embedding.data2vec(model_name='facebook/data2vec-audio-base-960h')) + .output('path', 'vecs') ) + +DataCollection(p('test.wav')).show() ``` +
diff --git a/result.png b/result.png new file mode 100644 index 0000000..74b9a29 Binary files /dev/null and b/result.png differ