audio_test / pipeline.py
osanseviero's picture
osanseviero HF staff
Create pipeline.py
25e3d78
from typing import Any, List, Tuple
import numpy as np
class PreTrainedPipeline():
def __init__(self, path=""):
# IMPLEMENT_THIS
# Preload all the elements you are going to need at inference.
# For instance your model, processors, tokenizer that might be needed.
# This function is only called once, so do all the heavy processing I/O here"""
self.sampling_rate = # IMPLEMENT THIS
raise NotImplementedError(
"Please implement PreTrainedPipeline __init__ function"
)
def __call__(self, inputs: np.array) -> Tuple[np.array, int, List[str]]:
"""
Args:
inputs (:obj:`np.array`):
The raw waveform of audio received. By default sampled at `self.sampling_rate`.
The shape of this array is `T`, where `T` is the time axis
Return:
A :obj:`tuple` containing:
- :obj:`np.array`:
The return shape of the array must be `C'`x`T'`
- a :obj:`int`: the sampling rate as an int in Hz.
- a :obj:`List[str]`: the annotation for each out channel.
This can be the name of the instruments for audio source separation
or some annotation for speech enhancement. The length must be `C'`.
"""
# IMPLEMENT_THIS
raise NotImplementedError(
"Please implement PreTrainedPipeline __call__ function"
)