osanseviero commited on
Commit
e7af9af
1 Parent(s): e7680da

Create pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +28 -0
pipeline.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Dict
2
+ import numpy as np
3
+
4
+ class PreTrainedPipeline():
5
+ def __init__(self, path=""):
6
+ # IMPLEMENT_THIS
7
+ # Preload all the elements you are going to need at inference.
8
+ # For instance your model, processors, tokenizer that might be needed.
9
+ # This function is only called once, so do all the heavy processing I/O here"""
10
+ self.sampling_rate = # IMPLEMENT THIS
11
+
12
+ raise NotImplementedError(
13
+ "Please implement PreTrainedPipeline __init__ function"
14
+ )
15
+
16
+ def __call__(self, inputs: np.array)-> Dict[str, str]:
17
+ """
18
+ Args:
19
+ inputs (:obj:`np.array`):
20
+ The raw waveform of audio received. By default at 16KHz.
21
+ Return:
22
+ A :obj:`dict`:. The object return should be liked {"text": "XXX"} containing
23
+ the detected text from the input audio.
24
+ """
25
+ # IMPLEMENT_THIS
26
+ raise NotImplementedError(
27
+ "Please implement PreTrainedPipeline __call__ function"
28
+ )