python_code
stringlengths
0
992k
repo_name
stringlengths
8
46
file_path
stringlengths
5
162
# Copyright (c) Facebook, Inc. All Rights Reserved import torch import os import numpy as np import pickle from . import retri from ..utils import get_local_rank class VectorPool(object): """ Base class of retrieval space. """ def __init__(self, config): from transformers import AutoConfig ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/mmpt/modules/vectorpool.py
# coding=utf-8 # Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team. # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a cop...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/mmpt/modules/mm.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import os import pickle from mmpt.utils import ShardedTensor class Shard(object): def __init__( self, ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/scripts/video_feature_extractor/shard_feature.py
# Copyright Howto100M authors. # Copyright (c) Facebook, Inc. All Rights Reserved import torch as th import pandas as pd import os import numpy as np import ffmpeg import random from torch.utils.data import Dataset class VideoLoader(Dataset): """modified from how2's video_feature_extractor.""" def __init__(...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/scripts/video_feature_extractor/videoreader.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import urllib.parse import json import pandas as pd from tqdm import tqdm # TODO: extending to other datasets. supported_formats =...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/scripts/video_feature_extractor/pathbuilder.py
# Copyright (c) Howto100M authors and Facebook, Inc. All Rights Reserved import torch as th from torch import nn class GlobalAvgPool(nn.Module): def __init__(self): super(GlobalAvgPool, self).__init__() def forward(self, x): return th.mean(x, dim=[-2, -1]) def get_model(args): assert ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/scripts/video_feature_extractor/model.py
# Copyright Howto100m authors. # Copyright (c) Facebook, Inc. All Rights Reserved import torch as th class Normalize(object): def __init__(self, mean, std): self.mean = th.FloatTensor(mean).view(1, 3, 1, 1) self.std = th.FloatTensor(std).view(1, 3, 1, 1) def __call__(self, tensor): t...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/scripts/video_feature_extractor/preprocessing.py
# Copyright Howto100M authors. # Copyright (c) Facebook, Inc. All Rights Reserved import torch as th import torch.nn.functional as F import math import numpy as np import argparse from torch.utils.data import DataLoader from model import get_model from preprocessing import Preprocessing from random_sequence_shuffler ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/scripts/video_feature_extractor/extract.py
# Copyright (c) Facebook, Inc. All Rights Reserved import numpy as np from torch.utils.data.sampler import Sampler class RandomSequenceSampler(Sampler): def __init__(self, n_sample, seq_len): self.n_sample = n_sample self.seq_len = seq_len def _pad_ind(self, ind): zeros = np.zeros(...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/scripts/video_feature_extractor/random_sequence_shuffler.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import pickle import os import argparse import numpy as np from torch.utils.data import Dataset, DataLoader from mmpt.processors import PKLJS...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/scripts/text_token_extractor/pretokenization.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import glob import argparse import pprint import omegaconf from omegaconf import OmegaConf from torch.utils.data import DataLoader ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/mmpt_cli/predict.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os from mmpt.utils import recursive_config class BaseJob(object): def __init__(self, yaml_file, dryrun=False): self.yaml_...
EXA-1-master
exa/models/unilm-master/edgelm/examples/MMPT/mmpt_cli/localjob.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import rxf_src # noqa
EXA-1-master
exa/models/unilm-master/edgelm/examples/rxf/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import label_smoothed_cross_entropy_r3f, sentence_prediction_r3f # noqa
EXA-1-master
exa/models/unilm-master/edgelm/examples/rxf/rxf_src/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from fairseq.criterions import FairseqCriterion, register_...
EXA-1-master
exa/models/unilm-master/edgelm/examples/rxf/rxf_src/sentence_prediction_r3f.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import metrics, utils from fairseq.criterions import FairseqCriterion, ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/rxf/rxf_src/label_smoothed_cross_entropy_r3f.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import transformer_xl_model, truncated_bptt_lm_task # noqa
EXA-1-master
exa/models/unilm-master/edgelm/examples/truncated_bptt/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os from dataclasses import dataclass, field from typing import List, Optional, Tuple import torch from fairseq import u...
EXA-1-master
exa/models/unilm-master/edgelm/examples/truncated_bptt/truncated_bptt_lm_task.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from dataclasses import dataclass, field from typing import Dict, List, Optional import torch from fairseq.dataclass import Fa...
EXA-1-master
exa/models/unilm-master/edgelm/examples/truncated_bptt/transformer_xl_model.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import tasks, criterions, models # noqa
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os from argparse import Namespace from pathlib import Path import torch from fairseq.data import ( encoders, Dic...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/tasks/speech_text_joint.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib import os
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/tasks/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging from collections import namedtuple import torch import torch.nn as nn from fairseq import checkpoint_utils from fairseq import...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/models/s2t_dualinputtransformer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib import os
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/models/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import copy import torch.nn as nn from fairseq import checkpoint_utils from fairseq import utils from fairseq.data.data_utils import lengths_...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/models/s2t_dualinputxmtransformer.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import itertools import logging import re import time from g2p_en import G2p logger = logging.getLogger(__name__) FAIL_SENT...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/scripts/g2p_encode.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq.criterions import FairseqCriterion, register_criterion from fairseq.crit...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/criterions/text_guide_cross_entropy_acc.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import importlib import os for file in os.listdir(os.path.dirname(__file__)): if file.endswith(".py") and not file.startswith("_"): ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_text_joint_to_text/criterions/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Helper script to pre-compute embeddings for a flashlight (previously called wav2letter++) dataset """ import argpa...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/wav2vec_featurize.py
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/__init__.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Data pre-processing: build vocabularies and binarize training data. """ import argparse import glob import os impor...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/wav2vec_manifest.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Helper script to pre-compute embeddings for a flashlight (previously called wav2letter++) dataset """ import argpa...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/libri_labels.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Helper script to pre-compute embeddings for a flashlight (previously called wav2letter++) dataset """ import argpa...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/vq-wav2vec_featurize.py
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/__init__.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Run inference for pre-processed data with a trained model. """ import ast from collections import namedtuple fr...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/w2vu_generate.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .unpaired_audio_text import UnpairedAudioText __all__ = [ "UnpairedAudioText", ]
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/tasks/__init__.py
# Copyright (c) 2017-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the LICENSE file in # the root directory of this source tree. An additional grant of patent rights # can be found in the PATENTS file in the same directory. from dataclasses import dataclass,...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/tasks/unpaired_audio_text.py
import kaldi_io import numpy as np import os def get_parser(): import argparse parser = argparse.ArgumentParser() parser.add_argument("w2v_dir", help="wav2vec feature and text directory") parser.add_argument("tar_root", help="output data directory in kaldi's format") parser.add_argument("split", h...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/kaldi_self_train/st/local/prepare_data_from_w2v.py
""" Implement unsupervised metric for decoding hyperparameter selection: $$ alpha * LM_PPL + ViterbitUER(%) * 100 $$ """ import argparse import logging import math import sys import kenlm import editdistance from g2p_en import G2p logging.root.setLevel(logging.INFO) logging.basicConfig(stream=sys.stdout, level=lo...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/kaldi_self_train/st/local/unsup_select.py
import sys for idx, line in enumerate(sys.stdin): print(f"utt{idx:010d} {line}", end='')
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/kaldi_self_train/st/local/copy_aligned_text.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass from enum import Enum, auto import math import numpy as np from typing import Tuple, List, Optional, Dict i...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/models/wav2vec_u.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .wav2vec_u import Wav2vec_U __all__ = [ "Wav2vec_U", ]
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/models/__init__.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import sys from copy import deepcopy from scipy.signal import lfilter import numpy as np from tqdm...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/vads.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import os.path as osp import numpy as np import tqdm import torch import sys import faiss...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/wav2vec_apply_cluster_faiss.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import gc import os import os.path as osp import random import numpy as np import tqdm import torch ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/wav2vec_cluster_faiss.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import argparse import sys parser = argparse.ArgumentParser() parser.add_argument("--tsv", required=True...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/filter_tsv.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import os.path as osp import numpy as np import tqdm import torch import random from shuti...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/merge_clusters.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys def main(): for line in sys.stdin: print(line.replace(" ", "").replace("|", " ").strip()) ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/ltr_to_wrd.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import numpy as np import sys def get_parser(): parser = argparse.ArgumentParser( desc...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/phonemize_with_sil.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import os.path as osp import math import numpy as np import tqdm import torch import torch...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/mean_pool.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys def main(): for line in sys.stdin: print(" ".join(list(line.strip().replace(" ", "|"))) + "...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/wrd_to_ltr.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import regex import sys def main(): filter_r = regex.compile(r"[^\p{L}\p{N}\p{M}\' \-]") for line in sys.std...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/normalize_text.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Implement unsupervised metric for decoding hyperparameter selection: $$ alpha * LM_PPL + ViterbitUER(%) * 10...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/wer.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import sys for idx, line in enumerate(sys.stdin): print(f"utt{idx:010d} {line}", end="")
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/copy_labels.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import os.path as osp import numpy as np import faiss def get_parser(): parser = a...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/pca.py
#!/usr/bin/env python3 # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import fasttext as ft import os import regex import sys def get_parser(): parser = argparse.Argum...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/normalize_and_filter_text.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import sys from fairseq.data import Dictionary def get_parser(): parser = argparse.ArgumentPa...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/filter_lexicon.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import os.path as osp import math import numpy as np import tqdm import torch from shutil ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/apply_pca.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import sys from g2p_en import G2p def main(): parser = argparse.ArgumentParser() parser.a...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/g2p_wrd_to_phn.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ get intervals from .vads file, specify output data, and this script removes silences and saves the audio data in...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/remove_silence.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import os import os.path as osp import tqdm import torch import torch.nn.functional as F from shutil...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/scripts/wav2vec_extract_features.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from .extracted_features_dataset import ExtractedFeaturesDataset from .random_input_dataset import RandomInputDataset __all__ = [ "Extra...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/data/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import os import contextlib import numpy as np import torch from fairseq.data import FairseqDataset, data_utils logger = l...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/data/extracted_features_dataset.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import random from typing import List from fairseq.data import BaseWrapperDataset, data_utils class RandomInputDataset(BaseWrapperDataset):...
EXA-1-master
exa/models/unilm-master/edgelm/examples/wav2vec/unsupervised/data/random_input_dataset.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import contextlib import sys from collections import Counter from multiprocessing imp...
EXA-1-master
exa/models/unilm-master/edgelm/examples/roberta/multiprocessing_bpe_encoder.py
#!/usr/bin/env python # Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. import argparse import json import os import re class InputExample: def __init__(self, paragrap...
EXA-1-master
exa/models/unilm-master/edgelm/examples/roberta/preprocess_RACE.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json from functools import lru_cache def convert_sentence_to_json(sentence): if "_" in sentence: prefix, rest = sentence....
EXA-1-master
exa/models/unilm-master/edgelm/examples/roberta/wsc/wsc_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairseq import utils from fairseq.criterions import LegacyFairseqCriterion, reg...
EXA-1-master
exa/models/unilm-master/edgelm/examples/roberta/wsc/wsc_criterion.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import wsc_criterion # noqa from . import wsc_task # noqa
EXA-1-master
exa/models/unilm-master/edgelm/examples/roberta/wsc/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json import os import tempfile import numpy as np import torch import torch.nn.functional as F from fairseq import utils from fairseq....
EXA-1-master
exa/models/unilm-master/edgelm/examples/roberta/wsc/wsc_task.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from . import commonsense_qa_task # noqa
EXA-1-master
exa/models/unilm-master/edgelm/examples/roberta/commonsense_qa/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import json import os import numpy as np import torch from fairseq.data import ( Dictionary, IdDataset, ListDataset, NestedDi...
EXA-1-master
exa/models/unilm-master/edgelm/examples/roberta/commonsense_qa/commonsense_qa_task.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import fileinput import sacremoses def main(): parser = argparse.ArgumentParser(description="...
EXA-1-master
exa/models/unilm-master/edgelm/examples/megatron_11b/detok.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import matplotlib.pyplot as plt import numpy as np from pathlib import Path import soundfile as sf import sys import torch imp...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/generate_waveform.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os from pathlib import Path from typing import Optional, List, Dict import zipfile import tempfile from dataclasses import dataclass fr...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/data_utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import numpy as np import torch from scipy.interpolate import interp1d import torchaudio from fairseq.tasks.text_to_speech import ( batch...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Signal processing-based evaluation using waveforms """ import csv import numpy as np import os.path as op import torch import tqdm from...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/evaluation/eval_sp.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import editdistance import re import shutil import soundfile as sf import subprocess from pathlib import Path from examples.s...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/evaluation/eval_asr.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Signal processing-based evaluation using waveforms """ import numpy as np import os.path as op import torchaudio import tqdm from tabulat...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/evaluation/eval_f0.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import csv from pathlib import Path def main(args): """ `uid syn ref text` """ in_root = Path(args.generation_root).resolve...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/evaluation/get_eval_manifest.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/evaluation/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging import numpy as np import re from pathlib import Path from collections import defaultdict import pandas as pd ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/get_vctk_audio_manifest.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse from collections import defaultdict from itertools import chain from pathlib import Path import numpy as np import torchaudi...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/get_speaker_embedding.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging from pathlib import Path from collections import defaultdict import pandas as pd from torchaudio.datasets impo...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/get_ljspeech_audio_manifest.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging from pathlib import Path import shutil from tempfile import NamedTemporaryFile from collections import Counter,...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/get_feature_manifest.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging from pathlib import Path from collections import defaultdict from typing import List, Dict, Tuple import panda...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/get_common_voice_audio_manifest.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import logging import os import csv import tempfile from collections import defaultdict from pathlib import Path import torch...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/denoise_and_vad_audio.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import librosa import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.data import torchaudio EMBEDDER_PARAMS...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/speaker_embedder/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # author: adefossez import logging import torch.hub from .demucs import Demucs from .utils import deserialize_model logg...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/denoiser/pretrained.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # author: adefossez import math import torch as th from torch.nn import functional as F def sinc(t): """sinc. :...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/denoiser/resample.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree.
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/denoiser/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # author: adefossez import functools import logging from contextlib import contextmanager import inspect import time logge...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/denoiser/utils.py
# Copyright (c) Facebook, Inc. and its affiliates. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # author: adefossez import math import time import torch as th from torch import nn from torch.nn import functional as F ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/denoiser/demucs.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import collections import contextlib import wave try: import webrtcvad except ImportError: raise ImportError("Please install py-webr...
EXA-1-master
exa/models/unilm-master/edgelm/examples/speech_synthesis/preprocessing/vad/__init__.py
from . import criterions, models, tasks # noqa
EXA-1-master
exa/models/unilm-master/edgelm/examples/discriminative_reranking_nmt/__init__.py
#!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. """ Score raw text with a trained model. """ from collections import namedtuple import logging from multiprocessing ...
EXA-1-master
exa/models/unilm-master/edgelm/examples/discriminative_reranking_nmt/drnmt_rerank.py
from .discriminative_reranking_task import DiscriminativeRerankingNMTTask __all__ = [ "DiscriminativeRerankingNMTTask", ]
EXA-1-master
exa/models/unilm-master/edgelm/examples/discriminative_reranking_nmt/tasks/__init__.py
# Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from dataclasses import dataclass, field import itertools import logging import os import numpy as np import torch from fairseq import metr...
EXA-1-master
exa/models/unilm-master/edgelm/examples/discriminative_reranking_nmt/tasks/discriminative_reranking_task.py