whisper-large_v2_test / good_handler.py
slplab's picture
Rename handler.py to good_handler.py
139c456
raw
history blame
No virus
677 Bytes
from typing import Dict, Any, List
from transformers import pipeline
import torch
#### USE of PIPELINE
class EndpointHandler:
def __init__(self, path=""):
self.pipe = pipeline(task='automatic-speech-recognition', model=path)
# Move model to device
# self.model.to(device)
def __call__(self, data: Any) -> List[Dict[str, str]]:
print('==========NEW PROCESS=========')
transcribe = self.pipe
transcribe.model.config.forced_decoder_ids = transcribe.tokenizer.get_decoder_prompt_ids(language="ko", task="transcribe")
result = transcribe(data['inputs'])
return result