File size: 1,021 Bytes
31a1b74
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# MIT_LICENSE file in the root directory of this source tree.

from pathlib import Path

import torch

from fairseq2.assets import InProcAssetMetadataProvider, asset_store


def add_gated_assets(model_dir: Path) -> None:
    asset_store.env_resolvers.append(lambda: "gated")

    model_dir = model_dir.resolve()

    gated_metadata = [
        {
            "name": "seamless_expressivity@gated",
            "checkpoint": model_dir.joinpath("m2m_expressive_unity.pt"),
        },
        {
            "name": "vocoder_pretssel@gated",
            "checkpoint": model_dir.joinpath("pretssel_melhifigan_wm.pt"),
        },
        {
            "name": "vocoder_pretssel_16khz@gated",
            "checkpoint": model_dir.joinpath("pretssel_melhifigan_wm-16khz.pt"),
        },
    ]

    asset_store.metadata_providers.append(InProcAssetMetadataProvider(gated_metadata))