-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
53 lines (44 loc) · 1.9 KB
/
config.py
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
import dataclasses
import logging
import pathlib
@dataclasses.dataclass
class ModelSpec:
name: str
params: str
relative_speed: int # Higher is faster
def get_logger(name, level=logging.INFO):
logger = logging.getLogger(name)
handler = logging.StreamHandler()
handler.setFormatter(
logging.Formatter("%(levelname)s: %(asctime)s: %(name)s %(message)s")
)
logger.addHandler(handler)
logger.setLevel(level)
logger.propagate = False # Prevent the modal client from double-logging.
return logger
CACHE_DIR = "/cache"
# Where downloaded podcasts are stored, by guid hash.
# Mostly .mp3 files 50-100MiB.
RAW_AUDIO_DIR = pathlib.Path(CACHE_DIR, "raw_audio")
# Stores metadata of individual podcast episodes as JSON.
PODCAST_METADATA_DIR = pathlib.Path(CACHE_DIR, "podcast_metadata")
# Completed episode transcriptions. Stored as flat files with
# files structured as '{guid_hash}-{model_slug}.json'.
TRANSCRIPTIONS_DIR = pathlib.Path(CACHE_DIR, "transcriptions")
# Searching indexing files, refreshed by scheduled functions.
SEARCH_DIR = pathlib.Path(CACHE_DIR, "search")
# Location of modal checkpoint.
MODEL_DIR = pathlib.Path(CACHE_DIR, "model")
# Location of web frontend assets.
ASSETS_PATH = pathlib.Path(__file__).parent / "frontend" / "dist"
transcripts_per_podcast_limit = 2
supported_whisper_models = {
"tiny.en": ModelSpec(name="tiny.en", params="39M", relative_speed=32),
# Takes around 3-10 minutes to transcribe a podcast, depending on length.
"base.en": ModelSpec(name="base.en", params="74M", relative_speed=16),
"small.en": ModelSpec(name="small.en", params="244M", relative_speed=6),
"medium.en": ModelSpec(name="medium.en", params="769M", relative_speed=2),
# Very slow. Will take around 45 mins to 1.5 hours to transcribe.
"large": ModelSpec(name="large", params="1550M", relative_speed=1),
}
DEFAULT_MODEL = supported_whisper_models["base.en"]