Spaces:
Running
Running
import abc | |
import numpy as np | |
class IASRModel(metaclass=abc.ABCMeta): | |
def __subclasshook__(cls, subclass): | |
return (hasattr(subclass, 'getTranscript') and | |
callable(subclass.getTranscript) and | |
hasattr(subclass, 'getWordLocations') and | |
callable(subclass.getWordLocations) and | |
hasattr(subclass, 'processAudio') and | |
callable(subclass.processAudio)) | |
def getTranscript(self) -> str: | |
"""Get the transcripts of the process audio""" | |
raise NotImplementedError | |
def getWordLocations(self) -> list: | |
"""Get the pair of words location from audio""" | |
raise NotImplementedError | |
def processAudio(self, audio): | |
"""Process the audio""" | |
raise NotImplementedError | |
class ITranslationModel(metaclass=abc.ABCMeta): | |
def __subclasshook__(cls, subclass): | |
return (hasattr(subclass, 'translateSentence') and | |
callable(subclass.translateSentence)) | |
def translateSentence(self, str) -> str: | |
"""Get the translation of the sentence""" | |
raise NotImplementedError | |
class ITextToSpeechModel(metaclass=abc.ABCMeta): | |
def __subclasshook__(cls, subclass): | |
return (hasattr(subclass, 'getAudioFromSentence') and | |
callable(subclass.getAudioFromSentence)) | |
def getAudioFromSentence(self, str) -> np.array: | |
"""Get audio from sentence""" | |
raise NotImplementedError | |
class ITextToPhonemModel(metaclass=abc.ABCMeta): | |
def __subclasshook__(cls, subclass): | |
return (hasattr(subclass, 'convertToPhonem') and | |
callable(subclass.convertToPhonem)) | |
def convertToPhonem(self, str) -> str: | |
"""Convert sentence to phonemes""" | |
raise NotImplementedError | |