repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
OFA | OFA-main/run_scripts/image_gen/eval_utils/dataset.py | from torch.utils import data
from PIL import Image
import os
class Dataset(data.Dataset):
'Characterizes a dataset for PyTorch'
def __init__(self, path, transform=None):
'Initialization'
self.file_names = self.get_filenames(path)
self.transform = transform
def __len__(self):
... | 1,077 | 29.8 | 70 | py |
OFA | OFA-main/fairseq/setup.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 os
import subprocess
import sys
from setuptools import Extension, find_packages, setup
if sys.version_info < (... | 8,365 | 28.354386 | 92 | py |
OFA | OFA-main/fairseq/hubconf.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.
"""isort:skip_file"""
import functools
import importlib
dependencies = [
"dataclasses",
"hydra",
"numpy",
"omegaconf",
"... | 2,099 | 27.378378 | 82 | py |
OFA | OFA-main/fairseq/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.
import logging
from dataclasses import dataclass, field
from typing import Dict, List, Optional
import torch
from fairseq.dataclass import Fa... | 5,324 | 33.134615 | 86 | py |
OFA | OFA-main/fairseq/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
import os
from dataclasses import dataclass, field
from typing import List, Optional, Tuple
import torch
from fairseq import u... | 9,900 | 34.109929 | 86 | py |
OFA | OFA-main/fairseq/examples/linformer/linformer_src/modules/multihead_linear_attention.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
from typing import Dict, Optional, Tuple
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.incr... | 19,151 | 38.73444 | 98 | py |
OFA | OFA-main/fairseq/examples/linformer/linformer_src/modules/linformer_sentence_encoder.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.nn as nn
from fairseq.models.transformer import TransformerEncoder
from .linformer_sentence_encoder_layer import Li... | 2,151 | 38.127273 | 85 | py |
OFA | OFA-main/fairseq/examples/linformer/linformer_src/modules/linformer_sentence_encoder_layer.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 torch
from fairseq import utils
from fairseq.modules import TransformerEncoderLayer
from .multihead_linear_attention import MultiheadL... | 2,743 | 40.575758 | 85 | py |
OFA | OFA-main/fairseq/examples/linformer/linformer_src/models/linformer_roberta.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.
"""
Linformer: Self-Attention with Linear Complexity
"""
import logging
import torch
from fairseq import utils
from fairseq.models import reg... | 4,143 | 33.247934 | 84 | py |
OFA | OFA-main/fairseq/examples/wav2vec/vq-wav2vec_featurize.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... | 7,680 | 29.601594 | 99 | py |
OFA | OFA-main/fairseq/examples/wav2vec/wav2vec_featurize.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... | 7,020 | 27.084 | 135 | py |
OFA | OFA-main/fairseq/examples/wav2vec/unsupervised/w2vu_generate.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... | 22,210 | 30.371469 | 129 | py |
OFA | OFA-main/fairseq/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 dataclasses import dataclass
from enum import Enum, auto
import math
import numpy as np
from typing import Tuple, List, Optional, Dict
i... | 20,954 | 31.844828 | 90 | py |
OFA | OFA-main/fairseq/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 os
import os.path as osp
import numpy as np
import tqdm
import torch
import sys
import faiss... | 4,015 | 30.131783 | 129 | py |
OFA | OFA-main/fairseq/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 argparse
import os
import os.path as osp
import numpy as np
import tqdm
import torch
import random
from shuti... | 3,543 | 29.817391 | 110 | py |
OFA | OFA-main/fairseq/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.
"""
get intervals from .vads file, specify output data, and this script removes silences and saves the audio data in... | 1,927 | 29.125 | 128 | py |
OFA | OFA-main/fairseq/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 os
import os.path as osp
import math
import numpy as np
import tqdm
import torch
from shutil ... | 2,496 | 31.428571 | 114 | py |
OFA | OFA-main/fairseq/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 argparse
import gc
import os
import os.path as osp
import random
import numpy as np
import tqdm
import torch
... | 6,315 | 28.933649 | 129 | py |
OFA | OFA-main/fairseq/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 argparse
import os
import os.path as osp
import math
import numpy as np
import tqdm
import torch
import torch... | 3,187 | 30.88 | 144 | py |
OFA | OFA-main/fairseq/examples/wav2vec/unsupervised/scripts/wav2vec_extract_features.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... | 3,673 | 29.616667 | 105 | py |
OFA | OFA-main/fairseq/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 logging
import os
import contextlib
import numpy as np
import torch
from fairseq.data import FairseqDataset, data_utils
logger = l... | 4,170 | 27.765517 | 87 | py |
OFA | OFA-main/fairseq/examples/wav2vec/unsupervised/tasks/unpaired_audio_text.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,... | 15,435 | 33.455357 | 102 | py |
OFA | OFA-main/fairseq/examples/criss/save_encoder.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.
"""
Translate pre-processed data with a trained model.
"""
import numpy as np
import torch
from fairseq import check... | 7,473 | 33.762791 | 90 | py |
OFA | OFA-main/fairseq/examples/bart/summarize.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 torch
from fairseq.models.bart import BARTModel
import argparse
XSUM_KWARGS = dict(beam=6, lenpen=1.0, max_len_b=60, min_len=10, no_re... | 3,174 | 30.435644 | 88 | py |
OFA | OFA-main/fairseq/examples/adaptive_span/adaptive_span_attention.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 as nn
import torch.nn.functional as F
class AdaptiveMask(nn.Module):
"""Soft masking function f... | 5,881 | 35.534161 | 85 | py |
OFA | OFA-main/fairseq/examples/adaptive_span/adagrad_with_grad_clip.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 torch.optim import Adagrad
from fairseq.optim import LegacyFairseqOptimizer, register_optimizer
@register_optimizer("adagrad_with_grad... | 4,374 | 32.914729 | 92 | py |
OFA | OFA-main/fairseq/examples/adaptive_span/adaptive_span_model.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.
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.modules.layer_norm import Lay... | 8,540 | 31.352273 | 87 | py |
OFA | OFA-main/fairseq/examples/adaptive_span/adaptive_span_loss.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
from dataclasses import dataclass
import torch.nn.functional as F
from fairseq import metrics, utils
from fairseq.criterions impo... | 4,233 | 38.570093 | 88 | py |
OFA | OFA-main/fairseq/examples/adaptive_span/adaptive_span_model_wrapper.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
from typing import Dict, List, Optional
import torch
from fairseq.dataclass import FairseqDa... | 4,692 | 31.143836 | 114 | py |
OFA | OFA-main/fairseq/examples/translation_moe/translation_moe_src/mean_pool_gating_network.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 torch
import torch.nn.functional as F
class MeanPoolGatingNetwork(torch.nn.Module):
"""A simple mean-pooling gating network for s... | 2,011 | 38.45098 | 84 | py |
OFA | OFA-main/fairseq/examples/translation_moe/translation_moe_src/logsumexp_moe.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 torch
class LogSumExpMoE(torch.autograd.Function):
"""Standard LogSumExp forward pass, but use *posterior* for the backward.
... | 837 | 30.037037 | 78 | py |
OFA | OFA-main/fairseq/examples/translation_moe/translation_moe_src/translation_moe.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 torch
from omegaconf import II
from fairseq import metrics, utils
from fairseq.dataclass impo... | 9,484 | 35.621622 | 95 | py |
OFA | OFA-main/fairseq/examples/laser/laser_src/laser_transformer.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 typing import Any, Dict, List, Optional
from torch import Tensor
import torch
import torch.nn as nn
from fairseq.models... | 11,947 | 32.656338 | 88 | py |
OFA | OFA-main/fairseq/examples/laser/laser_src/laser_lstm.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 torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq import options, utils
from fairseq.models import (
Fairs... | 20,672 | 34.278157 | 89 | py |
OFA | OFA-main/fairseq/examples/latent_depth/latent_depth_src/modules/latent_layers.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 torch
import torch.nn as nn
class LayerSelect(nn.Module):
"""Compute samples (from a Gumbel-Sigmoid distribution) which is used a... | 2,605 | 33.289474 | 83 | py |
OFA | OFA-main/fairseq/examples/latent_depth/latent_depth_src/models/latent_transformer.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 typing import Any, Dict, Optional
import torch.nn as nn
from fairseq.models.fairseq_encoder import EncoderOut
from fairseq.models.transf... | 5,584 | 34.573248 | 88 | py |
OFA | OFA-main/fairseq/examples/latent_depth/latent_depth_src/loss/latent_depth.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
from torch.nn.modules.loss import _Loss
class LatentLayersKLLoss(_Loss):
def __init__(self, args):
sup... | 3,802 | 37.03 | 86 | py |
OFA | OFA-main/fairseq/examples/hubert/update_ckpt.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 torch
src_ckpt = "/checkpoint/wnhsu/w2v/archived/hubert_base_ls960_it2.pt"
ref_ckpt = "/checkpoint/wnhsu/w2v/hubert_icassp_oss_v3/iter... | 873 | 37 | 209 | py |
OFA | OFA-main/fairseq/examples/hubert/simple_kmeans/dump_km_label.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 sys
import numpy as np
import joblib
import torch
import tqdm
logging.basicConfig(
format="%(asctime)s ... | 3,008 | 29.393939 | 69 | py |
OFA | OFA-main/fairseq/examples/hubert/simple_kmeans/dump_mfcc_feature.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 sys
import soundfile as sf
import torch
import torchaudio
from feature_utils import get_path_iterator, dump_... | 2,491 | 30.544304 | 78 | py |
OFA | OFA-main/fairseq/examples/hubert/simple_kmeans/dump_w2v2_feature.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 sys
import fairseq
import soundfile as sf
import torch
import torch.nn.functional as F
from feature_utils im... | 3,129 | 31.604167 | 78 | py |
OFA | OFA-main/fairseq/examples/hubert/simple_kmeans/dump_hubert_feature.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 sys
import fairseq
import soundfile as sf
import torch
import torch.nn.functional as F
from feature_utils im... | 3,018 | 31.117021 | 78 | py |
OFA | OFA-main/fairseq/examples/speech_to_text/prep_covost_data.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 logging
from pathlib import Path
import shutil
from tempfile import NamedTemporaryFile
from typi... | 8,909 | 30.821429 | 86 | py |
OFA | OFA-main/fairseq/examples/speech_to_text/prep_mtedx_data.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 logging
import os
from pathlib import Path
import shutil
from itertools import groupby
from temp... | 10,168 | 36.386029 | 80 | py |
OFA | OFA-main/fairseq/examples/speech_to_text/prep_librispeech_data.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 logging
from pathlib import Path
import shutil
from tempfile import NamedTemporaryFile
import p... | 3,623 | 29.2 | 77 | py |
OFA | OFA-main/fairseq/examples/speech_to_text/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 csv
from pathlib import Path
import zipfile
from functools import reduce
from multiprocessing import cpu_count
from typing import Any, ... | 12,226 | 30.924282 | 88 | py |
OFA | OFA-main/fairseq/examples/speech_to_text/prep_mustc_data.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 logging
import os
from pathlib import Path
import shutil
from itertools import groupby
from temp... | 11,012 | 36.715753 | 79 | py |
OFA | OFA-main/fairseq/examples/speech_to_text/simultaneous_translation/agents/fairseq_simul_st_agent.py | import math
import os
import json
import numpy as np
import torch
import torchaudio.compliance.kaldi as kaldi
import yaml
from fairseq import checkpoint_utils, tasks
from fairseq.file_io import PathManager
try:
from simuleval import READ_ACTION, WRITE_ACTION, DEFAULT_EOS
from simuleval.agents import SpeechAgen... | 12,193 | 32.5 | 105 | py |
OFA | OFA-main/fairseq/examples/roberta/commonsense_qa/commonsense_qa_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 json
import os
import numpy as np
import torch
from fairseq.data import (
Dictionary,
IdDataset,
ListDataset,
NestedDi... | 6,124 | 31.068063 | 88 | py |
OFA | OFA-main/fairseq/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.
import json
import os
import tempfile
import numpy as np
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.... | 13,524 | 32.644279 | 90 | py |
OFA | OFA-main/fairseq/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.
import math
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.criterions import LegacyFairseqCriterion, reg... | 6,037 | 34.940476 | 87 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/infer.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
import logging
import math
import os
... | 14,455 | 32.775701 | 111 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/w2l_decoder.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.
"""
Flashlight decoders.
"""
import gc
import itertools as it
import os.path as osp
from typing import List
import wa... | 17,396 | 34.722793 | 171 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/criterions/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.
from __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import torch
import torch.nn.f... | 5,372 | 40.015267 | 85 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/criterions/ASG_loss.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 torch
from examples.speech_recognition.data.replabels import pack_replabels
from fairseq import utils
from fair... | 5,870 | 33.333333 | 85 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/models/vggtransformer.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 math
from collections.abc import Iterable
import torch
import torch.nn as nn
from examples.speech_recognition.data.dat... | 37,260 | 35.494613 | 88 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/models/w2l_conv_glu_enc.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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.models import (
Fairs... | 6,078 | 33.151685 | 87 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/datasets/asr_prep_json.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.
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import concurrent.f... | 3,775 | 28.968254 | 84 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/new/infer.py | #!/usr/bin/env python -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 ast
import hashlib
import logging
import os
import shutil
import sys
from dataclasses import dataclass, field,... | 16,498 | 33.955508 | 103 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/new/decoders/base_decoder.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 itertools as it
from typing import Any, Dict, List
import torch
from fairseq.data.dictionary import Dictionary
from fairseq.models.fai... | 2,093 | 32.238095 | 85 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/new/decoders/viterbi_decoder.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 torch
from typing import List, Dict
from .base_decoder import BaseDecoder
class ViterbiDecoder(BaseDecoder)... | 641 | 24.68 | 73 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/new/decoders/flashlight_decoder.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 gc
import os.path as osp
import warnings
from collections import deque, namedtuple
from typing import Any, Dict... | 14,746 | 33.136574 | 88 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/kaldi/kaldi_decoder.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.
from concurrent.futures import ThreadPoolExecutor
import logging
from omegaconf import MISSING
import os
import torch
... | 8,265 | 32.738776 | 116 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/data/collaters.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.
"""
This module contains collection of classes which implement
collate functionalities for various tasks.
Collaters should know wh... | 4,796 | 35.340909 | 84 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/data/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 torch
def calc_mean_invstddev(feature):
if len(feature.size()) != 2:
raise ValueError("We expect the input feature to be ... | 3,429 | 32.960396 | 84 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/data/asr_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 os
import numpy as np
from fairseq.data import FairseqDataset
from . import data_utils
from .collaters import Seq2SeqCollater
class... | 3,955 | 31.162602 | 82 | py |
OFA | OFA-main/fairseq/examples/speech_recognition/tasks/speech_recognition.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 re
import sys
import torch
from examples.speech_recognition.data import AsrDataset
from examples.speech_recognit... | 5,397 | 33.164557 | 87 | py |
OFA | OFA-main/fairseq/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.
import logging
import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path
import soundfile as sf
import sys
import torch
imp... | 7,219 | 36.604167 | 80 | py |
OFA | OFA-main/fairseq/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.
import numpy as np
import torch
from scipy.interpolate import interp1d
import torchaudio
from fairseq.tasks.text_to_speech import (
batch... | 3,357 | 31.921569 | 78 | py |
OFA | OFA-main/fairseq/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 os
from pathlib import Path
from typing import Optional, List, Dict
import zipfile
import tempfile
from dataclasses import dataclass
fr... | 10,437 | 31.517134 | 80 | py |
OFA | OFA-main/fairseq/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.
"""
Signal processing-based evaluation using waveforms
"""
import csv
import numpy as np
import os.path as op
import torch
import tqdm
from... | 4,149 | 30.439394 | 75 | py |
OFA | OFA-main/fairseq/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.
"""
Signal processing-based evaluation using waveforms
"""
import numpy as np
import os.path as op
import torchaudio
import tqdm
from tabulat... | 8,333 | 30.213483 | 80 | py |
OFA | OFA-main/fairseq/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.
import argparse
import logging
from pathlib import Path
import shutil
from tempfile import NamedTemporaryFile
from collections import Counter,... | 9,928 | 41.431624 | 80 | py |
OFA | OFA-main/fairseq/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
from pathlib import Path
from collections import defaultdict
from typing import List, Dict, Tuple
import panda... | 5,277 | 36.432624 | 80 | py |
OFA | OFA-main/fairseq/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 argparse
import logging
import os
import csv
import tempfile
from collections import defaultdict
from pathlib import Path
import torch... | 7,655 | 36.346341 | 80 | py |
OFA | OFA-main/fairseq/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
from collections import defaultdict
import pandas as pd
from torchaudio.datasets impo... | 2,288 | 31.239437 | 80 | py |
OFA | OFA-main/fairseq/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
import logging
import numpy as np
import re
from pathlib import Path
from collections import defaultdict
import pandas as pd
... | 2,685 | 32.575 | 80 | py |
OFA | OFA-main/fairseq/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
from collections import defaultdict
from itertools import chain
from pathlib import Path
import numpy as np
import torchaudi... | 3,116 | 33.633333 | 81 | py |
OFA | OFA-main/fairseq/examples/speech_synthesis/preprocessing/denoiser/resample.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.
:... | 2,226 | 26.8375 | 89 | py |
OFA | OFA-main/fairseq/examples/speech_synthesis/preprocessing/denoiser/demucs.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
... | 16,989 | 34.843882 | 83 | py |
OFA | OFA-main/fairseq/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 functools
import logging
from contextlib import contextmanager
import inspect
import time
logge... | 4,770 | 25.954802 | 85 | py |
OFA | OFA-main/fairseq/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 logging
import torch.hub
from .demucs import Demucs
from .utils import deserialize_model
logg... | 2,384 | 28.085366 | 84 | py |
OFA | OFA-main/fairseq/examples/speech_synthesis/preprocessing/speaker_embedder/__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 librosa
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
import torchaudio
EMBEDDER_PARAMS... | 4,103 | 29.176471 | 78 | py |
OFA | OFA-main/fairseq/examples/byte_level_bpe/gru_transformer.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.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the r... | 5,027 | 45.555556 | 87 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/modules/monotonic_multihead_attention.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
from torch import Tensor
import torch.nn as nn
from examples.simultaneous_translation.utils.p_choose_strategy impor... | 16,858 | 31.421154 | 142 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/modules/monotonic_transformer_layer.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 fairseq.modules import TransformerDecoderLayer, TransformerEncoderLayer
from . import build_monotonic_attention
from typing import Dict... | 7,265 | 38.704918 | 88 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/modules/fixed_pre_decision.py | from functools import partial
import torch
from torch import Tensor
import math
import torch.nn.functional as F
from . import register_monotonic_attention
from .monotonic_multihead_attention import (
MonotonicAttention,
MonotonicInfiniteLookbackAttention,
WaitKAttention
)
from typing import Dict, Optional... | 7,370 | 37.591623 | 91 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/eval/agents/simul_t2t_enja.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 fairseq import checkpoint_utils, tasks
import sentencepiece as spm
import torch
try:
from simuleval import READ_ACTION, W... | 7,099 | 30.277533 | 85 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/models/transformer_monotonic_attention.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 typing import Dict, List, NamedTuple, Optional
import torch
import torch.nn as nn
from examples.simultaneous_translation.modules.monoton... | 10,185 | 32.617162 | 108 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/models/convtransformer_simul_trans.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 fairseq import checkpoint_uti... | 7,162 | 33.941463 | 123 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/tests/test_text_models.py | import argparse
import unittest
from typing import Any, Dict
import torch
from examples.simultaneous_translation.models import (
transformer_monotonic_attention
)
from tests.test_roberta import FakeTask
DEFAULT_CONFIG = {
"attention_eps": 1e-6,
"mass_preservation": True,
"noise_type": "flat",
"... | 13,524 | 32.14951 | 108 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/utils/monotonic_attention.py | from typing import Optional
import torch
from torch import Tensor
from examples.simultaneous_translation.utils.functions import (
exclusive_cumprod,
prob_check,
moving_sum,
)
def expected_alignment_from_p_choose(
p_choose: Tensor,
padding_mask: Optional[Tensor] = None,
eps: float = 1e-6
):
... | 5,473 | 26.507538 | 78 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/utils/p_choose_strategy.py | from typing import Optional, Dict
from torch import Tensor
import torch
def waitk_p_choose(
tgt_len: int,
src_len: int,
bsz: int,
waitk_lagging: int,
key_padding_mask: Optional[Tensor] = None,
incremental_state: Optional[Dict[str, Dict[str, Optional[Tensor]]]] = None
):
max_src_len = src_... | 3,445 | 26.133858 | 78 | py |
OFA | OFA-main/fairseq/examples/simultaneous_translation/utils/functions.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 torch
def prob_check(tensor, eps=1e-10):
assert not torch.isnan(tensor).any(), (
"Nan in a probability tensor."
)
... | 3,535 | 27.063492 | 84 | py |
OFA | OFA-main/fairseq/examples/fast_noisy_channel/noisy_channel_translation.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 fairseq.tasks.translation import TranslationTask
from fairseq.tasks.language_modeling import LanguageModelingTask
from fairseq import che... | 6,709 | 51.421875 | 160 | py |
OFA | OFA-main/fairseq/examples/fast_noisy_channel/noisy_channel_beam_search.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 torch
from fairseq.search import Search
class NoisyChannelBeamSearch(Search):
def __init__(self, tgt_dict):
super().__in... | 2,895 | 39.222222 | 104 | py |
OFA | OFA-main/fairseq/examples/fast_noisy_channel/noisy_channel_sequence_generator.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 typing import Dict, List, Optional
import math
import numpy as np
import torch
import torch.nn.functional as F
from torch import Tensor... | 41,200 | 47.874259 | 187 | py |
OFA | OFA-main/fairseq/examples/textless_nlp/gslm/ulm/sample.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.
"""
Sample from a trained LM; hacked fairseq-interactive
"""
from collections import namedtuple
import os
import ast
... | 5,623 | 31.137143 | 103 | py |
OFA | OFA-main/fairseq/examples/textless_nlp/gslm/tools/resynthesize_speech.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 gc
import logging
import joblib
import soundfile as sf
import torch
from examples.textless_nlp.gslm.speech2unit.pretra... | 4,073 | 28.309353 | 76 | py |
OFA | OFA-main/fairseq/examples/textless_nlp/gslm/unit2speech/tts_data.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 torch
import numpy as np
from examples.textless_nlp.gslm.unit2speech.tacotron2.text import (
EOS_TOK,
SOS_TOK,
code_to_seq... | 1,669 | 30.509434 | 77 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.