Skip to content

Transcriber

Transcriber

Bases: ABC

Interface to any ASR transcriber.

Source code in asrbench\transcribers\abc_transcriber.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class Transcriber(ABC):
    """Interface to any ASR transcriber."""

    @classmethod
    @abstractmethod
    def from_config(cls, name: str, config: Dict[str, Any]):
        """Create a new Transcriber from a name and configuration Dict.

        Arguments:
            name: Transcriber configuration name.
            config: Dict with Transcriber configuration.
        """
        raise NotImplementedError("Implement from_config method.")

    @property
    @abstractmethod
    def params(self) -> Dict[str, Any]:
        """Parameters passed in the Transcriber configuration."""
        raise NotImplementedError("Implement params property.")

    @property
    @abstractmethod
    def name(self) -> str:
        """Name given to the Transcriber setting in the configuration file."""
        raise NotImplementedError("Implement name property.")

    @abstractmethod
    def transcribe(self, audio_path: str) -> str:
        """Transcribes from the path of the audio file provided."""
        raise NotImplementedError("Implement transcribe method.")

    @abstractmethod
    def load(self) -> None:
        """Loads all the instances needed for Transcriber to work into
        memory."""
        raise NotImplementedError("Implement load model method.")

    @abstractmethod
    def unload(self) -> None:
        """Unloads all instances created by Transcriber from memory."""
        raise NotImplementedError("Implement unload model method.")

name: str abstractmethod property

Name given to the Transcriber setting in the configuration file.

params: Dict[str, Any] abstractmethod property

Parameters passed in the Transcriber configuration.

from_config(name, config) abstractmethod classmethod

Create a new Transcriber from a name and configuration Dict.

Parameters:

Name Type Description Default
name str

Transcriber configuration name.

required
config Dict[str, Any]

Dict with Transcriber configuration.

required
Source code in asrbench\transcribers\abc_transcriber.py
 8
 9
10
11
12
13
14
15
16
17
@classmethod
@abstractmethod
def from_config(cls, name: str, config: Dict[str, Any]):
    """Create a new Transcriber from a name and configuration Dict.

    Arguments:
        name: Transcriber configuration name.
        config: Dict with Transcriber configuration.
    """
    raise NotImplementedError("Implement from_config method.")

load() abstractmethod

Loads all the instances needed for Transcriber to work into memory.

Source code in asrbench\transcribers\abc_transcriber.py
36
37
38
39
40
@abstractmethod
def load(self) -> None:
    """Loads all the instances needed for Transcriber to work into
    memory."""
    raise NotImplementedError("Implement load model method.")

transcribe(audio_path) abstractmethod

Transcribes from the path of the audio file provided.

Source code in asrbench\transcribers\abc_transcriber.py
31
32
33
34
@abstractmethod
def transcribe(self, audio_path: str) -> str:
    """Transcribes from the path of the audio file provided."""
    raise NotImplementedError("Implement transcribe method.")

unload() abstractmethod

Unloads all instances created by Transcriber from memory.

Source code in asrbench\transcribers\abc_transcriber.py
42
43
44
45
@abstractmethod
def unload(self) -> None:
    """Unloads all instances created by Transcriber from memory."""
    raise NotImplementedError("Implement unload model method.")