Update handler.py
Browse files- handler.py +10 -8
handler.py
CHANGED
@@ -1,20 +1,22 @@
|
|
1 |
from typing import Dict, Any, List
|
2 |
from transformers import WhisperForConditionalGeneration, AutoProcessor, WhisperTokenizer, WhisperProcessor, pipeline, WhisperFeatureExtractor
|
3 |
import torch
|
4 |
-
import
|
5 |
-
|
|
|
|
|
6 |
|
7 |
|
8 |
class EndpointHandler:
|
9 |
def __init__(self, path=""):
|
10 |
-
tokenizer = WhisperTokenizer.from_pretrained('openai/whisper-large', language="korean", task='transcribe')
|
11 |
-
model = WhisperForConditionalGeneration.from_pretrained(path)
|
12 |
#self.tokenizer = WhisperTokenizer.from_pretrained(path)
|
13 |
#self.processor = WhisperProcessor.from_pretrained(path, language="korean", task='transcribe')
|
14 |
-
processor = AutoProcessor.from_pretrained(path)
|
15 |
#self.pipe = pipeline("automatic-speech-recognition", model=model, tokenizer=processor.feature_extractor, feature_extractor=processor.feature_extractor)
|
16 |
-
feature_extractor = WhisperFeatureExtractor.from_pretrained('openai/whisper-large')
|
17 |
-
self.pipe = pipeline(task='automatic-speech-recognition', model=path)
|
18 |
|
19 |
|
20 |
|
@@ -23,7 +25,7 @@ class EndpointHandler:
|
|
23 |
|
24 |
def __call__(self, data: Any) -> List[Dict[str, str]]:
|
25 |
print('==========NEW PROCESS=========')
|
26 |
-
transcribe = pipeline(task="automatic-speech-recognition", model="vasista22/whisper-kannada-tiny"
|
27 |
transcribe.model.config.forced_decoder_ids = transcribe.tokenizer.get_decoder_prompt_ids(language="ko", task="transcribe")
|
28 |
result = transcribe(data['inputs'])
|
29 |
|
|
|
1 |
from typing import Dict, Any, List
|
2 |
from transformers import WhisperForConditionalGeneration, AutoProcessor, WhisperTokenizer, WhisperProcessor, pipeline, WhisperFeatureExtractor
|
3 |
import torch
|
4 |
+
#import io
|
5 |
+
|
6 |
+
|
7 |
+
#device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
8 |
|
9 |
|
10 |
class EndpointHandler:
|
11 |
def __init__(self, path=""):
|
12 |
+
#tokenizer = WhisperTokenizer.from_pretrained('openai/whisper-large', language="korean", task='transcribe')
|
13 |
+
#model = WhisperForConditionalGeneration.from_pretrained(path)
|
14 |
#self.tokenizer = WhisperTokenizer.from_pretrained(path)
|
15 |
#self.processor = WhisperProcessor.from_pretrained(path, language="korean", task='transcribe')
|
16 |
+
#processor = AutoProcessor.from_pretrained(path)
|
17 |
#self.pipe = pipeline("automatic-speech-recognition", model=model, tokenizer=processor.feature_extractor, feature_extractor=processor.feature_extractor)
|
18 |
+
#feature_extractor = WhisperFeatureExtractor.from_pretrained('openai/whisper-large')
|
19 |
+
self.pipe = pipeline(task='automatic-speech-recognition', model=path, device=)
|
20 |
|
21 |
|
22 |
|
|
|
25 |
|
26 |
def __call__(self, data: Any) -> List[Dict[str, str]]:
|
27 |
print('==========NEW PROCESS=========')
|
28 |
+
transcribe = pipeline(task="automatic-speech-recognition", model="vasista22/whisper-kannada-tiny")
|
29 |
transcribe.model.config.forced_decoder_ids = transcribe.tokenizer.get_decoder_prompt_ids(language="ko", task="transcribe")
|
30 |
result = transcribe(data['inputs'])
|
31 |
|