-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtranscript_test.py
More file actions
67 lines (53 loc) · 1.99 KB
/
Copy pathtranscript_test.py
File metadata and controls
67 lines (53 loc) · 1.99 KB
1
2
3
4
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import argparse
from pathlib import Path
from typing import Callable, Optional
class TranscriptTest:
"""
Base class for transcript tests, all transcript tests should inherit from this class
"""
def __init__(self, model_name: str, language: str, **kwargs):
# transcriber is a function that takes a path to an audio file and returns a transcript
# should be provided by the model
self.transcriber: Optional[Callable] = None
# normalizer is a function that takes a transcript and returns a normalized transcript
# see libs/normalizers.py for examples
self.normalizer: Optional[Callable] = None
self.language: str = language
self.model_name: str = model_name
def additional_info(self) -> dict:
"""
Override this method, should return additional info about the test
Returns:
dict with additional info
"""
return {
"modelName": self.model_name,
"language": self.language,
}
@staticmethod
def subparser(subparser: argparse.ArgumentParser):
"""
Use this method to add arguments to the subparser
Args:
parser: parser to add arguments to
"""
pass
def transcribe(self, audio_path: Path) -> str:
"""
Override this method, should transcribe the audio file and return the transcript
Args:
audio_path: path to audio file
Returns:
Transcript
"""
raise NotImplementedError
def compare(self, model_transcript, target_transcript):
"""
Override this method, should compare the model transcript to the target transcript
Args:
model_transcript: transcript from the model
target_transcript: transcript from the target
Returns:
Results of the comparison
"""
raise NotImplementedError