snac-24khz-ST / README.md
Annuvin
Update README.md
0bc37e3 verified
metadata
base_model:
  - hubertsiuzdak/snac_24khz

SNAC in safetensors format.

import json
from pathlib import Path

import safetensors.torch
import torch
import torchaudio
from snac import SNAC

config = json.loads(Path("config.json").read_text(encoding="utf-8"))
model = SNAC(**config)
state_dict = safetensors.torch.load_file("model.safetensors")
model.load_state_dict(state_dict)
model.cuda().eval()

input, sr = torchaudio.load("input.wav")
input = torchaudio.functional.resample(input, sr, model.sampling_rate)
input = input.cuda().unsqueeze(0)

with torch.inference_mode():
    codes = model.encode(input)
    output = model.decode(codes)

output = output.cpu().squeeze(0)
torchaudio.save("output.wav", output, model.sampling_rate)