File size: 677 Bytes
139c456
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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