slplab commited on
Commit
26143fa
1 Parent(s): 86435c4

Update handler.py

Browse files
Files changed (1) hide show
  1. handler.py +6 -6
handler.py CHANGED
@@ -15,17 +15,17 @@ class EndpointHandler:
15
  self.tokenizer = WhisperTokenizer.from_pretrained('openai/whisper-large', language="korean", task='transcribe')
16
  self.model = WhisperForConditionalGeneration.from_pretrained(path)
17
  #self.tokenizer = WhisperTokenizer.from_pretrained(path)
18
- self.processor = WhisperProcessor.from_pretrained(path, language="korean", task='transcribe')
19
  #self.processor = AutoProcessor.from_pretrained(path)
20
  #self.pipe = pipeline("automatic-speech-recognition", model=model, tokenizer=processor.feature_extractor, feature_extractor=processor.feature_extractor)
21
- self.feature_extractor = WhisperFeatureExtractor.from_pretrained(path)
22
 
23
 
24
  # Move model to device
25
  # self.model.to(device)
26
 
27
  def __call__(self, data: Any) -> List[Dict[str, str]]:
28
- print('HELLO')
29
  #print(f"{data}")
30
  #inputs = data.pop("inputs", data)
31
  #print(f'1. inputs: {inputs}')
@@ -33,13 +33,13 @@ class EndpointHandler:
33
 
34
  inputs, _ = sf.read(io.BytesIO(data['inputs']))
35
  #inputs, _ = sf.read(data['inputs'])
36
- print(f'2. inputs: {inputs}')
37
 
38
  input_features = self.feature_extractor(inputs, sampling_rate=16000).input_features[0]
39
- print(f'3. input_features: {input_features}')
40
  input_features_tensor = torch.tensor(input_features).unsqueeze(0)
41
  input_ids = self.model.generate(input_features_tensor)
42
- print(f'4. input_ids: {input_ids}')
43
 
44
  transcription = self.tokenizer.batch_decode(input_ids, skip_special_tokens=True)[0]
45
 
 
15
  self.tokenizer = WhisperTokenizer.from_pretrained('openai/whisper-large', language="korean", task='transcribe')
16
  self.model = WhisperForConditionalGeneration.from_pretrained(path)
17
  #self.tokenizer = WhisperTokenizer.from_pretrained(path)
18
+ #self.processor = WhisperProcessor.from_pretrained(path, language="korean", task='transcribe')
19
  #self.processor = AutoProcessor.from_pretrained(path)
20
  #self.pipe = pipeline("automatic-speech-recognition", model=model, tokenizer=processor.feature_extractor, feature_extractor=processor.feature_extractor)
21
+ self.feature_extractor = WhisperFeatureExtractor.from_pretrained('openai/whisper-large')
22
 
23
 
24
  # Move model to device
25
  # self.model.to(device)
26
 
27
  def __call__(self, data: Any) -> List[Dict[str, str]]:
28
+ print('==========NEW PROCESS=========')
29
  #print(f"{data}")
30
  #inputs = data.pop("inputs", data)
31
  #print(f'1. inputs: {inputs}')
 
33
 
34
  inputs, _ = sf.read(io.BytesIO(data['inputs']))
35
  #inputs, _ = sf.read(data['inputs'])
36
+ #print(f'2. inputs: {inputs}')
37
 
38
  input_features = self.feature_extractor(inputs, sampling_rate=16000).input_features[0]
39
+ #print(f'3. input_features: {input_features}')
40
  input_features_tensor = torch.tensor(input_features).unsqueeze(0)
41
  input_ids = self.model.generate(input_features_tensor)
42
+ #(f'4. input_ids: {input_ids}')
43
 
44
  transcription = self.tokenizer.batch_decode(input_ids, skip_special_tokens=True)[0]
45