repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/fast_noisy_channel/__init__.py
examples/fast_noisy_channel/__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 noisy_channel_translation # noqa from . import noisy_channel_sequence_generator # noqa from . import noisy_channel_beam_search...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/fast_noisy_channel/noisy_channel_beam_search.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/__init__.py
examples/simultaneous_translation/__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 models # noqa
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/tests/test_alignment_train.py
examples/simultaneous_translation/tests/test_alignment_train.py
import unittest import numpy as np import torch import hypothesis.strategies as st from hypothesis import assume, given, settings from torch.testing._internal.common_utils import TestCase from examples.simultaneous_translation.utils.functions import exclusive_cumprod TEST_CUDA = torch.cuda.is_available() class Al...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/tests/test_text_models.py
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", "...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/models/transformer_monotonic_attention.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/models/__init__.py
examples/simultaneous_translation/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 importlib import os for file in sorted(os.listdir(os.path.dirname(__file__))): if file.endswith(".py") and not file.startswith("_...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/models/convtransformer_simul_trans.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/utils/monotonic_attention.py
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 ): ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/utils/p_choose_strategy.py
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_...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/utils/__init__.py
examples/simultaneous_translation/utils/__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 importlib import os # automatically import any Python files in the criterions/ directory for file in sorted(os.listdir(os.path.dirnam...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/utils/functions.py
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." ) ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/eval/agents/simul_t2t_enja.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/modules/fixed_pre_decision.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/modules/monotonic_multihead_attention.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/modules/__init__.py
examples/simultaneous_translation/modules/__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 import importlib from fairseq import registry ( build_monotonic_attention, register_monotonic_attention, MONOTONIC_ATT...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/simultaneous_translation/modules/monotonic_transformer_layer.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/rxf/__init__.py
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 rxf_src # noqa
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/rxf/rxf_src/sentence_prediction_r3f.py
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 utils from fairseq.criterions import FairseqCriterion, register_...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/rxf/rxf_src/label_smoothed_cross_entropy_r3f.py
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. import math import torch import torch.nn.functional as F from fairseq import utils from fairseq.logging import metrics from fairseq.criterion...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/rxf/rxf_src/__init__.py
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. from . import label_smoothed_cross_entropy_r3f, sentence_prediction_r3f # noqa
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/speech_to_text_head_selection.py
examples/attention_head_selection/src/speech_to_text_head_selection.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.optim.amp_optimizer import AMPOptimizer from fairseq.tasks import register_task from fairseq.tasks.speech_to_text im...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/__init__.py
examples/attention_head_selection/src/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/loss/__init__.py
examples/attention_head_selection/src/loss/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/loss/attention_head_selection.py
examples/attention_head_selection/src/loss/attention_head_selection.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 HeadSelectionLoss(_Loss): def __init__(self, args): sup...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/models/head_selection_transformer.py
examples/attention_head_selection/src/models/head_selection_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, List, Dict, Optional import torch import torch.nn as nn from torch import Tensor from fairseq.utils import safe_hasat...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/models/head_selection_s2t_transformer.py
examples/attention_head_selection/src/models/head_selection_s2t_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 Dict, List, Optional from pathlib import Path import torch.nn as nn from torch import Tensor from fairseq im...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/models/__init__.py
examples/attention_head_selection/src/models/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/modules/head_selection_transformer_layer.py
examples/attention_head_selection/src/modules/head_selection_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.utils import safe_getattr from fairseq.modules import TransformerEncoderLayer, TransformerDecoderLayer from ..modules.multihead_a...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/modules/attn_head_selector.py
examples/attention_head_selection/src/modules/attn_head_selector.py
# 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 math class AttnHeadSelector(nn.Module): """ Latent variable modeling of attention head selection """ def __init__( self, num_ta...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/modules/multihead_functional.py
examples/attention_head_selection/src/modules/multihead_functional.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 Optional, Tuple import torch from torch import Tensor from torch.nn.functional import ( linear, softmax, dropout, pad, ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/modules/multihead_attention_selection.py
examples/attention_head_selection/src/modules/multihead_attention_selection.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, Optional, Tuple import torch from fairseq import utils from fairseq.modules.quant_noise import quant_noise from torch...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/modules/__init__.py
examples/attention_head_selection/src/modules/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/data/speech_to_text_dataset_with_domain.py
examples/attention_head_selection/src/data/speech_to_text_dataset_with_domain.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 pathlib import Path from typing import Dict, List, Optional from dataclasses import dataclass import torch from fairseq.d...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/attention_head_selection/src/data/__init__.py
examples/attention_head_selection/src/data/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/data_utils.py
examples/textless_nlp/pgslm/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 import torch from tqdm import tqdm class Stat: def __init__(self, keep_raw=False): self.x = 0.0 self.x2 = 0.0 ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/naive_decoder.py
examples/textless_nlp/pgslm/naive_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 torch import warnings class Naive_F0_Decoder(torch.nn.Module): def __init__(self, bounds_path, n_units=32): super().__init...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/preprocess_f0.py
examples/textless_nlp/pgslm/preprocess_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 os import torch from tqdm import tqdm from data_utils import load_audio_path from fairseq.data.codedataset import get_f0_by_filename d...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/generate_waveform.py
examples/textless_nlp/pgslm/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 ast import argparse import json import logging from pathlib import Path import soundfile as sf import torch from tqdm import tqdm fro...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/inference_dataset.py
examples/textless_nlp/pgslm/inference_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 torch class InferenceDataset: def __init__( self, dataset, prefix, only_prefix=True, pres...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/prepare_dataset.py
examples/textless_nlp/pgslm/prepare_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. from multiprocessing import Pool import os from collections import defaultdict from itertools import starmap import torch from npy_append_arr...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/truncated_laplace.py
examples/textless_nlp/pgslm/truncated_laplace.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 warnings def truncated_laplace(mean, T, truncate_by_zero=False): """Generating a sample from a Laplace distribution, ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/quantize_f0.py
examples/textless_nlp/pgslm/quantize_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. from collections import defaultdict from functools import partial import numpy as np import torch from tqdm import tqdm from data_utils impor...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/scripts/join_units_manifest.py
examples/textless_nlp/pgslm/scripts/join_units_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 json import argparse import pathlib def main(): parser = argparse.ArgumentParser() parser.add_argument("--manifest", required=...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/eval/cont_metrics.py
examples/textless_nlp/pgslm/eval/cont_metrics.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 import scipy import torch import torch.multiprocessing as mp from fairseq import checkpoint_utils, options from ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/eval/__init__.py
examples/textless_nlp/pgslm/eval/__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.
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/sample/__init__.py
examples/textless_nlp/pgslm/sample/__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.
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/pgslm/sample/sample.py
examples/textless_nlp/pgslm/sample/sample.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 torch.multiprocessing as mp import numpy as np import json import torch from torch.distributions.categorical import Categori...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/dgslm/sample_speech_dlm.py
examples/textless_nlp/dgslm/sample_speech_dlm.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 ast import argparse import logging import torch from fairseq import utils from fairseq.models.speech_dlm import SpeechDLM l...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/dgslm/dgslm_utils.py
examples/textless_nlp/dgslm/dgslm_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 import json from fairseq import utils from fairseq.models.text_to_speech.vocoder import CodeHiFiGANVocoder #...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/dgslm/create_code_file.py
examples/textless_nlp/dgslm/create_code_file.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 def main(): """ Create code file with the following format: {'audio': 'file1', 'unitA': 'file1_chnl1_units',...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/dgslm/vocoder_hifigan/generate_stereo_waveform.py
examples/textless_nlp/dgslm/vocoder_hifigan/generate_stereo_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 ast import argparse import json import logging from pathlib import Path import soundfile as sf import torch from tqdm import tqdm fro...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/tools/resynthesize_speech.py
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 os import joblib import soundfile as sf import torch from examples.textless_nlp.gslm.speech2u...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/ulm/sample.py
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 ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/metrics/abx_metrics/dump_abx_feats.py
examples/textless_nlp/gslm/metrics/abx_metrics/dump_abx_feats.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 joblib import numpy as np from examples.textless_nlp.gslm.speech2unit.clustering.utils impor...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/metrics/asr_metrics/self_auto_bleu.py
examples/textless_nlp/gslm/metrics/asr_metrics/self_auto_bleu.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 nltk from misc.bleu_utils import sentence_bleu import warnings def get_target_sequences(manifest, ground_truth, to...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/metrics/asr_metrics/ppx.py
examples/textless_nlp/gslm/metrics/asr_metrics/ppx.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 import warnings def get_target_sequences(manifest, ground_truth, to_take=1000): import json import ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/metrics/asr_metrics/continuation_eval.py
examples/textless_nlp/gslm/metrics/asr_metrics/continuation_eval.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 collections import defaultdict import numpy as np from misc.bleu_utils import sentence_bleu import json import warnings def get_args()...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/metrics/asr_metrics/misc/cut_as.py
examples/textless_nlp/gslm/metrics/asr_metrics/misc/cut_as.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 torchaudio import argparse import json import pathlib def get_args(): parser = argparse.ArgumentParser( "Assuring genera...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/metrics/asr_metrics/misc/bleu_utils.py
examples/textless_nlp/gslm/metrics/asr_metrics/misc/bleu_utils.py
""" TODO: the code is take from Apache-2 Licensed NLTK: make sure we do this properly! Copied over from nltk.tranlate.bleu_score. This code has two major changes: - allows to turn off length/brevity penalty --- it has no sense for self-bleu, - allows to use arithmetic instead of geometric mean """ import math imp...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tts_data.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/synthesize_audio_from_units.py
examples/textless_nlp/gslm/unit2speech/synthesize_audio_from_units.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 soundfile as sf from examples.textless_nlp.gslm.unit2speech.tts_data import ( TacotronInp...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/utils.py
examples/textless_nlp/gslm/unit2speech/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 from examples.textless_nlp.gslm.unit2speech.tacotron2.model import Tacotron2 from examples.textless_nlp.gslm.unit2speech.tacotro...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/convert_to_16k.py
examples/textless_nlp/gslm/unit2speech/convert_to_16k.py
import os import shlex import subprocess import progressbar from time import time from pathlib import Path def find_all_files(path_dir, extension): out = [] for root, dirs, filenames in os.walk(path_dir): for f in filenames: if f.endswith(extension): out.append(((str(Path(f)...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/multiproc.py
examples/textless_nlp/gslm/unit2speech/multiproc.py
import os import time import torch import sys import subprocess argslist = list(sys.argv)[1:] log_dir = argslist[-1] num_gpus = torch.cuda.device_count() argslist.append('--n_gpus={}'.format(num_gpus)) workers = [] job_id = time.strftime("%Y_%m_%d-%H%M%S") argslist.append("--group_name=group_{}".format(job_id)) print...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/glow.py
examples/textless_nlp/gslm/unit2speech/glow.py
# ***************************************************************************** # Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # * Redistributions...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/cmudict.py
examples/textless_nlp/gslm/unit2speech/tacotron2/cmudict.py
""" from https://github.com/keithito/tacotron """ import re valid_symbols = [ 'AA', 'AA0', 'AA1', 'AA2', 'AE', 'AE0', 'AE1', 'AE2', 'AH', 'AH0', 'AH1', 'AH2', 'AO', 'AO0', 'AO1', 'AO2', 'AW', 'AW0', 'AW1', 'AW2', 'AY', 'AY0', 'AY1', 'AY2', 'B', 'CH', 'D', 'DH', 'EH', 'EH0', 'EH1', 'EH2', 'ER', 'ER0', 'ER1', 'E...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/symbols.py
examples/textless_nlp/gslm/unit2speech/tacotron2/symbols.py
""" from https://github.com/keithito/tacotron """ ''' Defines the set of symbols used in text input to the model. The default is a set of ASCII characters that works well for English or text that has been run through Unidecode. For other data, you can modify _characters. See TRAINING_DATA.md for details. ''' from . i...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/stft.py
examples/textless_nlp/gslm/unit2speech/tacotron2/stft.py
""" BSD 3-Clause License Copyright (c) 2017, Prem Seetharaman All rights reserved. * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/cleaners.py
examples/textless_nlp/gslm/unit2speech/tacotron2/cleaners.py
""" from https://github.com/keithito/tacotron """ ''' Cleaners are transformations that run over the input text at both training and eval time. Cleaners can be selected by passing a comma-delimited list of cleaner names as the "cleaners" hyperparameter. Some cleaners are English-specific. You'll typically want to use...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/numbers.py
examples/textless_nlp/gslm/unit2speech/tacotron2/numbers.py
""" from https://github.com/keithito/tacotron """ import inflect import re _inflect = inflect.engine() _comma_number_re = re.compile(r'([0-9][0-9\,]+[0-9])') _decimal_number_re = re.compile(r'([0-9]+\.[0-9]+)') _pounds_re = re.compile(r'£([0-9\,]*[0-9]+)') _dollars_re = re.compile(r'\$([0-9\.\,]*[0-9]+)') _ordinal_r...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/audio_processing.py
examples/textless_nlp/gslm/unit2speech/tacotron2/audio_processing.py
import torch import numpy as np from scipy.signal import get_window import librosa.util as librosa_util def window_sumsquare(window, n_frames, hop_length=200, win_length=800, n_fft=800, dtype=np.float32, norm=None): """ # from librosa 0.6 Compute the sum-square envelope of a window fu...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/model.py
examples/textless_nlp/gslm/unit2speech/tacotron2/model.py
from math import sqrt import torch import torch.distributions as distr from torch.autograd import Variable from torch import nn from torch.nn import functional as F from .layers import ConvNorm, LinearNorm, GlobalAvgPool from .utils import to_gpu, get_mask_from_lengths class LocationLayer(nn.Module): def __init__...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/utils.py
examples/textless_nlp/gslm/unit2speech/tacotron2/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 collections import io import json import librosa import numpy as np import soundfile as sf import time import torch from scipy.io.wavfi...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/waveglow_denoiser.py
examples/textless_nlp/gslm/unit2speech/tacotron2/waveglow_denoiser.py
# import sys # sys.path.append('tacotron2') import torch from .layers import STFT class Denoiser(torch.nn.Module): """ Removes model bias from audio produced with waveglow """ def __init__(self, waveglow, filter_length=1024, n_overlap=4, win_length=1024, mode='zeros'): super(Denoiser...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/__init__.py
examples/textless_nlp/gslm/unit2speech/tacotron2/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/text.py
examples/textless_nlp/gslm/unit2speech/tacotron2/text.py
""" from https://github.com/keithito/tacotron """ import numpy as np import re from . import cleaners from .symbols import symbols # Mappings from symbol to numeric ID and vice versa: _symbol_to_id = {s: i for i, s in enumerate(symbols)} _id_to_symbol = {i: s for i, s in enumerate(symbols)} # Regular expression matc...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/unit2speech/tacotron2/layers.py
examples/textless_nlp/gslm/unit2speech/tacotron2/layers.py
import torch from librosa.filters import mel as librosa_mel_fn from .audio_processing import dynamic_range_compression from .audio_processing import dynamic_range_decompression from .stft import STFT from .utils import get_mask_from_lengths class LinearNorm(torch.nn.Module): def __init__(self, in_dim, out_dim, bi...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/__init__.py
examples/textless_nlp/gslm/speech2unit/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/clustering/dump_feats.py
examples/textless_nlp/gslm/speech2unit/clustering/dump_feats.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 examples.textless_nlp.gslm.speech2unit.pretrained.utils import ( get_and_dump_features, ) def get_p...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/clustering/quantize_with_kmeans.py
examples/textless_nlp/gslm/speech2unit/clustering/quantize_with_kmeans.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 numpy as np import joblib from examples.textless_nlp.gslm.speech2unit.clustering.utils impor...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/clustering/utils.py
examples/textless_nlp/gslm/speech2unit/clustering/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. from typing import List, Tuple def get_audio_files(manifest_path: str) -> Tuple[str, List[str], List[int]]: fnames, sizes = [], [] w...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/clustering/cluster_kmeans.py
examples/textless_nlp/gslm/speech2unit/clustering/cluster_kmeans.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 time import numpy as np from sklearn.cluster import MiniBatchKMeans import joblib from examp...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/clustering/__init__.py
examples/textless_nlp/gslm/speech2unit/clustering/__init__.py
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/pretrained/hubert_feature_reader.py
examples/textless_nlp/gslm/speech2unit/pretrained/hubert_feature_reader.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 fairseq import soundfile as sf import torch.nn.functional as F class HubertFeatureReader: """ Wrapper class to r...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/pretrained/logmel_feature_reader.py
examples/textless_nlp/gslm/speech2unit/pretrained/logmel_feature_reader.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 soundfile as sf import torch import torchaudio.compliance.kaldi as kaldi class LogMelFeatureReader: """ Wrapper class to run ...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/pretrained/utils.py
examples/textless_nlp/gslm/speech2unit/pretrained/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 gc import os import random import shutil import numpy as np import torch import tqdm from examples.textless_nlp.gslm.speech2unit.pretr...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/pretrained/cpc_feature_reader.py
examples/textless_nlp/gslm/speech2unit/pretrained/cpc_feature_reader.py
import soundfile as sf import torch import torch.nn as nn import torch.nn.functional as F class CpcFeatureReader: """ Wrapper class to run inference on CPC model. Helps extract features for a given audio file. """ def __init__( self, checkpoint_path, layer, use_enc...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/textless_nlp/gslm/speech2unit/pretrained/w2v2_feature_reader.py
examples/textless_nlp/gslm/speech2unit/pretrained/w2v2_feature_reader.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 fairseq import soundfile as sf class Wav2VecFeatureReader: """ Wrapper class to run inference on Wav2Vec 2.0 mod...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/backtranslation/deduplicate_lines.py
examples/backtranslation/deduplicate_lines.py
#!/usr/bin/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 fileinput import hashlib import sys from multiprocessing import Pool def get_hashes_and_lines(raw_...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/backtranslation/extract_bt_data.py
examples/backtranslation/extract_bt_data.py
#!/usr/bin/env python # 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 from tqdm import tqdm def main(): parser = argparse.ArgumentParser( desc...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/roberta/preprocess_RACE.py
examples/roberta/preprocess_RACE.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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/roberta/multiprocessing_bpe_encoder.py
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 contextlib import sys from collections import Counter from multiprocessing imp...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/roberta/commonsense_qa/commonsense_qa_task.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/roberta/commonsense_qa/__init__.py
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. from . import commonsense_qa_task # noqa
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/roberta/wsc/wsc_utils.py
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 json from functools import lru_cache def convert_sentence_to_json(sentence): if "_" in sentence: prefix, rest = sentence....
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/roberta/wsc/wsc_task.py
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....
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/roberta/wsc/wsc_criterion.py
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...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/roberta/wsc/__init__.py
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. from . import wsc_criterion # noqa from . import wsc_task # noqa
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false
facebookresearch/fairseq
https://github.com/facebookresearch/fairseq/blob/3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99/examples/unsupervised_quality_estimation/meteor.py
examples/unsupervised_quality_estimation/meteor.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 import os import subprocess import sys import tempfile from collections import defaultdict from itertools import c...
python
MIT
3d262bb25690e4eb2e7d3c1309b1e9c406ca4b99
2026-01-04T14:42:59.188867Z
false