Fix: Define missing audio input and required imports in example code
#3
by
anon-repair-bot
- opened
Description
This PR fixes a runtime error in the example code of the model card.
The following line triggered an exception at runtime:
NameError: name 'audio' is not defined
In addition, the code was missing two necessary import statements required to define the custom model class.
Changes
Replaced:
class HubertModelWithFinalProj(HubertModel):
def __init__(self, config):
super().__init__(config)
...
x = model(audio)["last_hidden_state"]
with:
from transformers import HubertModel
import torch.nn as nn
class HubertModelWithFinalProj(HubertModel):
def __init__(self, config):
super().__init__(config)
...
audio = torch.randn(1, 16000)
x = model(audio)["last_hidden_state"]
Testing
The code has been successfully tested and runs without error.
Note
This contribution is part of an ongoing research initiative to systematically identify and correct faulty example code in Hugging Face Model Cards.
We would appreciate a timely review and integration of this patch to support code reliability and enhance reproducibility for downstream users.
lengyue233
changed pull request status to
merged