osanseviero commited on
Commit
25e3d78
1 Parent(s): ed067ae

Create pipeline.py

Browse files
Files changed (1) hide show
  1. pipeline.py +35 -0
pipeline.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Any, List, Tuple
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
+
11
+ self.sampling_rate = # IMPLEMENT THIS
12
+
13
+ raise NotImplementedError(
14
+ "Please implement PreTrainedPipeline __init__ function"
15
+ )
16
+
17
+ def __call__(self, inputs: np.array) -> Tuple[np.array, int, List[str]]:
18
+ """
19
+ Args:
20
+ inputs (:obj:`np.array`):
21
+ The raw waveform of audio received. By default sampled at `self.sampling_rate`.
22
+ The shape of this array is `T`, where `T` is the time axis
23
+ Return:
24
+ A :obj:`tuple` containing:
25
+ - :obj:`np.array`:
26
+ The return shape of the array must be `C'`x`T'`
27
+ - a :obj:`int`: the sampling rate as an int in Hz.
28
+ - a :obj:`List[str]`: the annotation for each out channel.
29
+ This can be the name of the instruments for audio source separation
30
+ or some annotation for speech enhancement. The length must be `C'`.
31
+ """
32
+ # IMPLEMENT_THIS
33
+ raise NotImplementedError(
34
+ "Please implement PreTrainedPipeline __call__ function"
35
+ )