Project Alpha 1

This commit is contained in:
Elizabeth Cray
2024-10-10 10:51:48 -04:00
parent c03af29cc6
commit 120c1f7abc
7 changed files with 157 additions and 0 deletions

21
transcribe.py Normal file
View File

@@ -0,0 +1,21 @@
import torch
from transformers import AutoModelForSpeechSeq2Seq, AutoProcessor, pipeline
def process(audio_path):
model = AutoModelForSpeechSeq2Seq.from_pretrained(
"openai/whisper-large-v3",
torch_dtype=torch.float32,
low_cpu_mem_usage=True,
use_safetensors=True
)
model.to("mps")
processor = AutoProcessor.from_pretrained("openai/whisper-large-v3")
pipe = pipeline(
"automatic-speech-recognition",
model=model,
tokenizer=processor.tokenizer,
feature_extractor=processor.feature_extractor,
torch_dtype=torch.float32,
device="mps"
)
output = pipe(audio_path)["text"]
return output