Beispiel #1
0
def load_model(
    device,
    model_path: str,
):
    with open('labels.json') as label_file:
        labels = json.load(label_file)

    hparams = {
        "model": {
            "hidden_size": 1024,
            "hidden_layers": 5,
        },
        "audio_conf": {
            "sample_rate": 16000,
            "window_size": .02,
            "window_stride": .01,
            "window": "hamming",
        },
        "num_classes": len(labels)
    }

    model = DeepSpeech.load_from_checkpoint(
        checkpoint_path=to_absolute_path(model_path),
        hparams=hparams,
        decoder=None,
    )
    model.to(device)
    model.eval()
    return model
Beispiel #2
0
def load_model(device, model_path):
    model = DeepSpeech.load_from_checkpoint(
        hydra.utils.to_absolute_path(model_path))
    model.eval()
    model = model.to(device)
    return model