Skip to content

Latest commit

 

History

History
47 lines (37 loc) · 1.58 KB

README.md

File metadata and controls

47 lines (37 loc) · 1.58 KB

Encodec Stereo Example

FROM https://github.com/facebookresearch/encodec https://huggingface.co/docs/transformers/main/en/model_doc/encodec https://huggingface.co/datasets/ashraq/esc50?row=0

This project provides a simple example of using encodec in stereo mode with torchaudio.

Prerequisites

Make sure you have installed the required dependencies using the following command: Tips : facebookresearch/encodec#12

Usage

Download a stereo audio file (e.g., a WAV file with two channels) that you want to use with encodec.

Use torchaudio to load the audio file in stereo mode:

Copy code
import torchaudio

audio_file_path = "path/to/your_audio_file_stereo.wav"
waveform, sample_rate = torchaudio.load(audio_file_path, num_channels=2)
Install and use encodec to encode the audio signal:
Copy code
from transformers import EncodecModel, AutoProcessor, EncodecConfig

# Load the encodec model
configuration = EncodecConfig(audio_channels=2)
model = EncodecModel(configuration)

# Encode the audio signal
inputs = processor(waveform, return_tensors="pt")
outputs = model(**inputs)

# Access the embeddings
audio_codes = outputs.audio_codes
audio_values = outputs.audio_values
Explore and use the generated embeddings based on your specific needs.

Tips and Notes

Ensure that your audio file is in stereo format (two channels). Refer to the documentation of torchaudio and encodec for more information on available options and parameters. Contributing If you find issues or want to make improvements, feel free to open an issue or propose a pull request.