Views
No views yet
| Model | Input audio sampling rate [khz] |
|---|---|
hance-ai/descript-audio-codec-44khz | 44.1khz |
hance-ai/descript-audio-codec-24khz | 24khz |
hance-ai/descript-audio-codec-16khz | 16khz |
requirements.txt.1from transformers import AutoModel
2
3# device setting
4device = 'cpu' # or 'cuda:0'
5
6# load
7model = AutoModel.from_pretrained('hance-ai/descript-audio-codec-24khz', trust_remote_code=True)
8model.to(device)1audio_filename = 'path/example_audio.wav'
2zq, s = model.encode(audio_filename)zq is discrete embeddings with dimension of (1, num_RVQ_codebooks, token_length) and s is a token sequence with dimension of (1, num_RVQ_codebooks, token_length).1# decoding from `zq`
2waveform = model.decode(zq=zq) # (1, 1, audio_length); the output has a mono channel.
3
4# decoding from `s`
5waveform = model.decode(s=s) # (1, 1, audio_length); the output has a mono channel.model.waveform_to_audiofile(waveform, 'out.wav')1model.save_tensor(s, 'tokens.pt')
2loaded_s = model.load_tensor('tokens.pt')