Sponsored by
Vmake Labs Video Enhancer
-Vmake Labs Video Enhancer uses AI to improve video quality, restore details, reduce blur, and upscale videos to 8K.
from datasets import load_dataset
from transformers import Wav2Vec2ForCTC
import torchaudio
import torch
ds = load_dataset("patrickvonplaten/librispeech_asr_dummy", "clean", split="validation")
model = Wav2Vec2ForCTC.from_pretrained("patrickvonplaten/wav2vec2_tiny_random")
defload_audio(batch):
batch["samples"], _ = torchaudio.load(batch["file"])
return batch
ds = ds.map(load_audio)
input_values = torch.nn.utils.rnn.pad_sequence([torch.tensor(x[0]) for x in ds["samples"][:10]], batch_first=True)
# forward
logits = model(input_values).logits
pred_ids = torch.argmax(logits, dim=-1)
# dummy loss
dummy_labels = pred_ids.clone()
dummy_labels[dummy_labels == model.config.pad_token_id] = 1# can't have CTC blank token in label
dummy_labels = dummy_labels[:, -(dummy_labels.shape[1] // 4):] # make sure labels are shorter to avoid "inf" loss (can still happen though...)
loss = model(input_values, labels=dummy_labels).loss
Runs of patrickvonplaten wav2vec2_tiny_random on huggingface.co
569
Total runs
0
24-hour runs
-194
3-day runs
-1.2K
7-day runs
-2.0K
30-day runs
More Information About wav2vec2_tiny_random huggingface.co Model
wav2vec2_tiny_random huggingface.co
wav2vec2_tiny_random huggingface.co is an AI model on huggingface.co that provides wav2vec2_tiny_random's model effect (), which can be used instantly with this patrickvonplaten wav2vec2_tiny_random model. huggingface.co supports a free trial of the wav2vec2_tiny_random model, and also provides paid use of the wav2vec2_tiny_random. Support call wav2vec2_tiny_random model through api, including Node.js, Python, http.
wav2vec2_tiny_random huggingface.co is an online trial and call api platform, which integrates wav2vec2_tiny_random's modeling effects, including api services, and provides a free online trial of wav2vec2_tiny_random, you can try wav2vec2_tiny_random online for free by clicking the link below.
patrickvonplaten wav2vec2_tiny_random online free url in huggingface.co:
wav2vec2_tiny_random is an open source model from GitHub that offers a free installation service, and any user can find wav2vec2_tiny_random on GitHub to install. At the same time, huggingface.co provides the effect of wav2vec2_tiny_random install, users can directly use wav2vec2_tiny_random installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
wav2vec2_tiny_random install url in huggingface.co: