text
stringlengths
1
93.6k
"result" : [{
"conf" : 0.998515,
"end" : 0.750000,
"phones" : "l_B uu_I l_I e_E",
"start" : 0.270000,
"word" : "luule"
}, {
"conf" : 0.995148,
"end" : 1.379826,
"phones" : "k_B o_I k_I u_E",
"start" : 0.750000,
"word" : "__kogu"
}, {
"conf" : 1.000000,
"end" : 2.100000,
"phones" : "t_B o_I l_I m_I u_I s_I t_E",
"start" : 1.560000,
"word" : "tolmust"
}, {
"conf" : 1.000000,
"end" : 2.220000,
"phones" : "j_B a_E",
"start" : 2.100000,
"word" : "ja"
}, {
"conf" : 1.000000,
"end" : 3.000000,
"phones" : "v_B ae_I r_I v_I i_I t_I e_I s_I t_E",
"start" : 2.220000,
"word" : "värvidest"
}],
"text" : "luule __kogu tolmust ja värvidest"
}
post_processed = "luulekogu tolmust ja värvidest ."
result2 = reconstruct_full_result(result, post_processed)
assert result2["text"] == "luulekogu tolmust ja värvidest ."
assert result2["result"][0]["word"] == "luulekogu"
assert result2["result"][0]["start"] == 0.27
assert result2["result"][0]["end"] == 1.379826
#breakpoint()
# <FILESEP>
from typing import List, Tuple
import hydra
import pytorch_lightning as pl
from omegaconf import DictConfig
from pytorch_lightning import LightningDataModule, LightningModule, Trainer
from pytorch_lightning.loggers import Logger
# ------------------------------------------------------------------------------------ #
# the setup_root above is equivalent to:
# - adding project root dir to PYTHONPATH
# (so you don't need to force user to install project as a package)
# (necessary before importing any local modules e.g. `from src import utils`)
# - setting up PROJECT_ROOT environment variable
# (which is used as a base for paths in "configs/paths/default.yaml")
# (this way all filepaths are the same no matter where you run the code)
# - loading environment variables from ".env" in root dir
#
# you can remove it if you:
# 1. either install project as a package or move entry files to project root dir
# 2. set `root_dir` to "." in "configs/paths/default.yaml"
#
# more info: https://github.com/ashleve/pyrootutils
# ------------------------------------------------------------------------------------ #
from src import utils
log = utils.get_pylogger(__name__)
@utils.task_wrapper
def evaluate(cfg: DictConfig) -> Tuple[dict, dict]:
"""Evaluates given checkpoint on a datamodule testset.
This method is wrapped in optional @task_wrapper decorator which applies extra utilities
before and after the call.
Args:
cfg (DictConfig): Configuration composed by Hydra.
Returns:
Tuple[dict, dict]: Dict with metrics and dict with all instantiated objects.
"""
assert cfg.ckpt_path
if cfg.get("seed"):
pl.seed_everything(cfg.seed)
log.info(f"Instantiating datamodule <{cfg.data._target_}>")
datamodule: LightningDataModule = hydra.utils.instantiate(cfg.data)
log.info(f"Instantiating model <{cfg.model._target_}>")
model: LightningModule = hydra.utils.instantiate(cfg.model)
log.info("Instantiating loggers...")
logger: List[Logger] = utils.instantiate_loggers(cfg.get("logger"))