This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def signal2int(signal, sample_rate=16_000, seq_length=4): | |
""" | |
Decode a sine wave signal back into digits | |
""" | |
digits = [] | |
for start_index in range(0, sample_rate * seq_length, sample_rate): | |
end_index = start_index + sample_rate - 1 | |
window_samples = signal[start_index:end_index] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import reduce | |
input = 1 | |
f1 = lambda i: i+1 | |
f2 = lambda i: i+2 | |
f3 = lambda i: i+3 | |
output = reduce(lambda i, f: f(i), [f1, f2, f3], input) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torchaudio | |
fakewav_80mins = torch.rand(1, 16_000 * 60 * 80) | |
torchaudio.save("tmp/80mins.wav", fakewav_80mins, 16_000) | |
import nemo.collections.asr as nemo_asr | |
asr_model = nemo_asr.models.EncDecCTCModelBPE.from_pretrained(model_name="nvidia/stt_en_fastconformer_ctc_large") | |
asr_model.eval() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torchaudio | |
import pandas as pd | |
from pathlib import Path | |
from tqdm import tqdm | |
llight10h = torchaudio.datasets.LibriLightLimited(root="tmp/", subset="10h", download=True) | |
manifest_rows = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn.functional as F | |
from torch.utils.data import Dataset, DataLoader | |
import os | |
import torchaudio | |
from lhotse import CutSet, Fbank, FbankConfig | |
from lhotse.dataset import IterableDatasetWrapper, SpeechSynthesisDataset, DynamicBucketingSampler, OnTheFlyFeatures, make_worker_init_fn | |
from lhotse.recipes import download_librispeech, prepare_librispeech | |
from tqdm import tqdm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from transformers import Wav2Vec2Model | |
from torchaudio.models.wav2vec2.utils import import_huggingface_model | |
hf_model = Wav2Vec2Model.from_pretrained("facebook/wav2vec2-xls-r-300m") | |
ta_model = import_huggingface_model(hf_model) | |
torch.save(ta_model.state_dict(), "tmp/wav2vec2-300m_xls-r.pt") | |
## Usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20230710_mini-librispeech/ | |
├── dev | |
│ ├── cuts.000000.jsonl.gz | |
│ ├── cuts.000001.jsonl.gz | |
│ ├── cuts.000002.jsonl.gz | |
│ ├── cuts.000003.jsonl.gz | |
│ ├── cuts.000004.jsonl.gz | |
│ ├── cuts.000005.jsonl.gz | |
│ ├── fbank.000000.tar | |
│ ├── fbank.000001.tar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_instantiated_object: | |
_target_: my_classes.my_abstract_class.MyAbstractClass | |
my_variable: used Hydra YAML! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Modified version with diff (see history) | |
class TokenCollater: | |
"""Collate list of tokens | |
Map sentences to integers. Sentences are padded to equal length. | |
Beginning and end-of-sequence symbols can be added. | |
Call .inverse(tokens_batch, tokens_lens) to reconstruct batch as string sentences. | |
Example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
# Basic range in for loop | |
for value in {1..8} | |
do | |
echo "Starting backup $value" | |
rclone copy -P --exclude checkpoint_last.pt /home/nay/w2v2-fairseq-pretrain/outputs/2023-04-09/08-12-57/checkpoints/ gdrive_slasr:asr/checkpoints/xls-r_cpt_malay-140h/checkpoints/35-ga16/ | |
echo "Sleeping for 1 hour" | |
sleep 1h | |
done |
NewerOlder