mict-zhaw commited on
Commit
791642a
1 Parent(s): 7179598

Add requirements.txt

Browse files
Files changed (2) hide show
  1. handler.py +4 -8
  2. requirements.txt +3 -0
handler.py CHANGED
@@ -1,6 +1,4 @@
1
- import os.path
2
  from typing import Dict, List, Any
3
- import soundfile as sf
4
  import torch
5
  from pyctcdecode import build_ctcdecoder
6
  from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor, Wav2Vec2Tokenizer, Wav2Vec2ProcessorWithLM, Wav2Vec2FeatureExtractor, Wav2Vec2CTCTokenizer
@@ -12,8 +10,6 @@ class EndpointHandler:
12
 
13
  print("init")
14
 
15
- self.model_name = "mict-zhaw/chall_wav2vec2_xlsr_300m"
16
-
17
  self.pipeline = pipeline("automatic-speech-recognition", model=path)
18
 
19
  # Preload all the elements you are going to need at inference.
@@ -61,10 +57,6 @@ class EndpointHandler:
61
  decoder=language_model_decoder
62
  )
63
 
64
- def preprocess(self, audio_input):
65
- inputs = self.processor(audio_input, sampling_rate=sample_rate, return_tensors="pt", padding=True)
66
- return inputs
67
-
68
  def __call__(self, inputs: Dict[str, Any]) -> List[Dict[str, Any]]:
69
  """
70
  data args:
@@ -74,6 +66,10 @@ class EndpointHandler:
74
  A :obj:`list` | `dict`: will be serialized and returned
75
  """
76
 
 
 
 
 
77
  if "audio_file_path" in inputs.keys():
78
  audio_file_path = inputs.pop("audio_file_path")
79
  prediction = self.pipeline(audio_file_path)
 
 
1
  from typing import Dict, List, Any
 
2
  import torch
3
  from pyctcdecode import build_ctcdecoder
4
  from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor, Wav2Vec2Tokenizer, Wav2Vec2ProcessorWithLM, Wav2Vec2FeatureExtractor, Wav2Vec2CTCTokenizer
 
10
 
11
  print("init")
12
 
 
 
13
  self.pipeline = pipeline("automatic-speech-recognition", model=path)
14
 
15
  # Preload all the elements you are going to need at inference.
 
57
  decoder=language_model_decoder
58
  )
59
 
 
 
 
 
60
  def __call__(self, inputs: Dict[str, Any]) -> List[Dict[str, Any]]:
61
  """
62
  data args:
 
66
  A :obj:`list` | `dict`: will be serialized and returned
67
  """
68
 
69
+ print("inputs")
70
+ print(inputs)
71
+
72
+
73
  if "audio_file_path" in inputs.keys():
74
  audio_file_path = inputs.pop("audio_file_path")
75
  prediction = self.pipeline(audio_file_path)
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ torch
2
+ pyctcdecode
3
+ transformers