test / app.py
mskov's picture
Update app.py
084283c
raw
history blame
1.46 kB
import os
import sys
os.system("pip install transformers==4.27.0")
os.system("pip install torch")
os.system("pip install openai")
os.system("pip install accelerate")
from transformers import pipeline, WhisperModel, WhisperTokenizer, WhisperFeatureExtractor, AutoFeatureExtractor, AutoProcessor, WhisperConfig
os.system("pip install evaluate")
#import evaluate
#os.system("pip install evaluate[evaluator]")
os.system("pip install datasets")
# os.system("pip install llvmlite")
os.system("pip install spicy==1.8.1")
os.system("pip install soundfile")
os.system("pip install jiwer")
os.system("pip install datasets[audio]")
os.system("pip install numba==0.51.2")
import torch
from evaluate import evaluator
from datasets import load_dataset, Audio, disable_caching, set_caching_enabled
set_caching_enabled(False)
disable_caching()
huggingface_token = os.environ["huggingface_token"]
model = WhisperModel.from_pretrained("mskov/whisper_miso", use_auth_token=huggingface_token)
feature_extractor = AutoFeatureExtractor.from_pretrained("mskov/whisper_miso", use_auth_token=huggingface_token)
model_config = WhisperConfig.from_pretrained("mskov/whisper_miso", use_auth_token=huggingface_token)
model = WhisperModel(config=model_config)
model.load_state_dict(torch.load("mskov/whisper_miso/pytorch_model.bin", use_auth_token=huggingface_token))
model.eval()
dataset = load_dataset("mskov/miso_test", split="test").cast_column("audio", Audio())
print(dataset)