Spaces:
Runtime error
Runtime error
Commit
·
ab6de8f
1
Parent(s):
76b33ae
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
|
|
| 1 |
import torch
|
| 2 |
import torchaudio
|
| 3 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Tokenizer
|
| 4 |
|
|
|
|
|
|
|
|
|
|
| 5 |
# Load the pre-trained model and tokenizer
|
| 6 |
-
model_name = "BrendaTellez/
|
| 7 |
-
model = Wav2Vec2ForCTC.from_pretrained(model_name)
|
| 8 |
-
tokenizer = Wav2Vec2Tokenizer.from_pretrained(model_name)
|
| 9 |
|
| 10 |
# Get the audio file from the user
|
| 11 |
file_path = input("Enter the path to the audio file: ")
|
|
@@ -29,3 +33,4 @@ predicted_class_id = torch.argmax(logits, dim=-1)
|
|
| 29 |
predicted_class_label = tokenizer.decode(predicted_class_id[0])
|
| 30 |
|
| 31 |
print(f"The audio file is classified as: {predicted_class_label}")
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
import torch
|
| 3 |
import torchaudio
|
| 4 |
from transformers import Wav2Vec2ForCTC, Wav2Vec2Tokenizer
|
| 5 |
|
| 6 |
+
# Set the Hugging Face API token
|
| 7 |
+
os.environ["HUGGINGFACE_TOKEN"] = "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"
|
| 8 |
+
|
| 9 |
# Load the pre-trained model and tokenizer
|
| 10 |
+
model_name = "BrendaTellez/SoundClassification"
|
| 11 |
+
model = Wav2Vec2ForCTC.from_pretrained(model_name, use_auth_token=True)
|
| 12 |
+
tokenizer = Wav2Vec2Tokenizer.from_pretrained(model_name, use_auth_token=True)
|
| 13 |
|
| 14 |
# Get the audio file from the user
|
| 15 |
file_path = input("Enter the path to the audio file: ")
|
|
|
|
| 33 |
predicted_class_label = tokenizer.decode(predicted_class_id[0])
|
| 34 |
|
| 35 |
print(f"The audio file is classified as: {predicted_class_label}")
|
| 36 |
+
|