Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Karpnv/cc #35

Open
wants to merge 137 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
40d271e
commoncrawl
karpnv Sep 12, 2023
c4ea5e4
batch
karpnv Sep 12, 2023
4ebc195
rm filter
karpnv Sep 12, 2023
d9b3473
add caption
karpnv Sep 25, 2023
9a74b30
proxy_fields
karpnv Sep 25, 2023
f2c8f2b
duration_threshold
karpnv Sep 25, 2023
199bc22
big
karpnv Sep 25, 2023
f450f42
small
karpnv Sep 25, 2023
1952828
yaml
karpnv Sep 29, 2023
c9614f8
FfmpegConvert
karpnv Sep 29, 2023
e911070
ASR_HF
karpnv Oct 9, 2023
1097672
args
karpnv Oct 9, 2023
d90cd61
duration_key
karpnv Oct 20, 2023
d3973c8
nfa
karpnv Oct 20, 2023
6170682
source_audio
karpnv Oct 20, 2023
bf5ada0
dsalign
karpnv Oct 23, 2023
075a08a
audio_duration
karpnv Oct 26, 2023
e065608
EvalBandwidth and AlignerSubprocess
karpnv Oct 26, 2023
dd9f260
split CreateInitialManifestCC
karpnv Nov 2, 2023
1282ffb
split CreateInitialManifestCC
karpnv Nov 2, 2023
c1396ad
key_field
karpnv Nov 2, 2023
fbee380
offline_diar_infer
karpnv Nov 8, 2023
7fc4c1e
arm
karpnv Nov 8, 2023
7661d8e
duplicates
karpnv Nov 9, 2023
718a812
drop_text_duplicates
karpnv Nov 9, 2023
8bfdfc9
mcv
karpnv Nov 9, 2023
ad51e5d
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Nov 10, 2023
6b4a9a6
split
karpnv Nov 10, 2023
860ed6a
it nl eu
karpnv Nov 10, 2023
17953c4
TrainDevTestSplitCC
karpnv Nov 13, 2023
b6f16c0
merge
karpnv Nov 13, 2023
b69bfc1
en split
karpnv Nov 15, 2023
6942e61
Merge branch 'karpnv/cc' of github.com:NVIDIA/NeMo-speech-data-proces…
karpnv Nov 15, 2023
3813285
rm pandas
karpnv Nov 16, 2023
5979d5d
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Nov 16, 2023
5d30d6a
text processing for MCV PR
karpnv Nov 17, 2023
aa21b87
path
karpnv Nov 17, 2023
9d5e195
RandomPart
karpnv Nov 21, 2023
ad10221
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Nov 22, 2023
5b7700f
random_state
karpnv Nov 24, 2023
c724601
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Nov 24, 2023
2473855
docstring
karpnv Nov 24, 2023
96dfaed
split common processors
karpnv Nov 28, 2023
424edf7
langs
karpnv Nov 28, 2023
0e2ca51
audio_books
karpnv Nov 28, 2023
293648b
mv
karpnv Nov 28, 2023
970b9e7
mv todata_to_data
karpnv Dec 1, 2023
f8c5961
mv torch
karpnv Dec 1, 2023
a412180
PR comments
karpnv Dec 5, 2023
2208d03
paths
karpnv Dec 5, 2023
460cbbb
rename
karpnv Dec 5, 2023
f3cebd2
import
karpnv Dec 5, 2023
9a8d4f2
docs
karpnv Dec 5, 2023
c3ba8c9
subprocess
karpnv Dec 6, 2023
21005a2
Subprocess
karpnv Dec 11, 2023
9995909
fix docs
karpnv Dec 11, 2023
8cfdf39
CreateInitialManifestByExt doc
karpnv Dec 11, 2023
af7ca03
drop_abs_path
karpnv Dec 11, 2023
289a52f
Merge branch 'karpnv/cc' of github.com:NVIDIA/NeMo-speech-data-proces…
karpnv Dec 11, 2023
c12b732
add lang
karpnv Dec 12, 2023
f310b01
deps
karpnv Dec 14, 2023
7b7df73
PreserveByValue
karpnv Dec 14, 2023
a688b8a
GetSourceFolder
karpnv Dec 14, 2023
c196b50
drop Attributes
karpnv Dec 14, 2023
4f22ff2
args
karpnv Dec 14, 2023
9a9831c
rm methods
karpnv Dec 14, 2023
f869773
rm Note
karpnv Dec 14, 2023
4224052
more fixes
karpnv Dec 15, 2023
8289f82
header
karpnv Dec 18, 2023
bd42a6c
ASRWhisper
karpnv Dec 18, 2023
b2c1f0d
AudioLid args
karpnv Jan 9, 2024
a4d1173
merge
karpnv Jan 9, 2024
8537977
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Jan 9, 2024
7935e44
GetSpecificFiles CopyFiles
karpnv Jan 16, 2024
cdf330a
Merge branch 'karpnv/cc' of github.com:NVIDIA/NeMo-speech-data-proces…
karpnv Jan 16, 2024
39ec1a3
separate dev test
karpnv Jan 18, 2024
980eeb7
rm
karpnv Jan 22, 2024
f39d1d3
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Jan 22, 2024
165c295
black
karpnv Jan 22, 2024
8cd5896
self.torch_dtype
karpnv Jan 22, 2024
43ff82d
mv to cv
karpnv Jan 22, 2024
a24e6c9
mv configs
karpnv Jan 22, 2024
157de3a
rename
karpnv Jan 23, 2024
af69829
ManifestToUtf8
karpnv Jan 26, 2024
4c8a210
black
karpnv Feb 8, 2024
b1b45bc
not in
karpnv Feb 8, 2024
fc30b34
black
karpnv Feb 9, 2024
ee1c52e
add ASRWhisper
karpnv Feb 9, 2024
3dcc2f7
requirements
karpnv Feb 9, 2024
61c8fe7
test audio_books.yaml
karpnv Feb 9, 2024
f7182f2
add docs
karpnv Feb 26, 2024
2d5ee5b
black
karpnv Feb 26, 2024
81716ba
lanID
karpnv Feb 27, 2024
33b4f62
srt
karpnv Feb 27, 2024
e4ebfa7
load_manifest
karpnv Feb 27, 2024
dadf773
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Feb 28, 2024
ab7e1d9
docs
karpnv Feb 29, 2024
e63f250
black
karpnv Feb 29, 2024
714a7d1
key
karpnv Mar 1, 2024
fcee183
nemo file
karpnv Mar 15, 2024
c076199
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Mar 15, 2024
464c44b
black
karpnv Mar 15, 2024
5efdbcd
key style
karpnv Mar 15, 2024
981d5bd
rm PreserveByValue
karpnv Mar 15, 2024
a1e3fab
black
karpnv Mar 15, 2024
ab8c685
rm operator
karpnv Mar 19, 2024
f31f7d1
batch_size > 1
karpnv Mar 19, 2024
b734db4
Merge branch 'armenian' of github.com:NVIDIA/NeMo-speech-data-process…
karpnv Mar 19, 2024
02b35a8
German Youtube with new processors (#49)
ssh-meister Mar 19, 2024
f862b2a
black
karpnv Mar 19, 2024
c1ee056
merge
karpnv Mar 19, 2024
e2fe178
black
karpnv Mar 20, 2024
8f99da0
proxy
karpnv Mar 20, 2024
df15c33
New processors for calculating metrics (#50)
ssh-meister Mar 21, 2024
3434b7c
beamsearch
karpnv May 9, 2024
082d168
yaml
karpnv May 9, 2024
c6fe2a5
chunk_manifest
karpnv May 14, 2024
e68d3fe
get_capitalisation_from_target
karpnv May 16, 2024
0b34b9f
ConcatManifests
karpnv May 17, 2024
4aeb88c
utf8
karpnv May 21, 2024
421bad6
shell bool
karpnv May 27, 2024
a3e56d7
LangIdWhisper
karpnv May 29, 2024
52c8552
black
karpnv May 31, 2024
3614723
Merge branch 'karpnv/cc' of github.com:NVIDIA/NeMo-speech-data-proces…
karpnv May 31, 2024
dc64941
Updated LangIDWhisper processor (#62)
ssh-meister Jun 1, 2024
d16ff14
resolve conflicts
karpnv Jun 13, 2024
47a6875
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Jun 27, 2024
bb28efc
kenlm_path fix
karpnv Sep 4, 2024
7163a88
merge main
karpnv Sep 4, 2024
c71f558
add ApplyLlama3 and pnc pipeline
karpnv Sep 27, 2024
4441a2a
Merge branch 'main' of github.com:NVIDIA/NeMo-speech-data-processor i…
karpnv Oct 14, 2024
1b8c189
black
karpnv Nov 24, 2024
3810d3b
rm yt'
karpnv Nov 24, 2024
f02f37a
rm sdp/processors/datasets/yt
karpnv Nov 24, 2024
9d492e9
whitespace
karpnv Nov 24, 2024
82f58e0
rm llm
karpnv Nov 24, 2024
e9bb5db
rm extra langs
karpnv Nov 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated LangIDWhisper processor (#62)
Signed-off-by: Sasha Meister <[email protected]>
Co-authored-by: Sasha Meister <[email protected]>
  • Loading branch information
ssh-meister and sashameister authored Jun 1, 2024
commit dc64941127f3047a291ac19aa65bf399ebe3dc4c
60 changes: 46 additions & 14 deletions sdp/processors/huggingface/speech_recognition.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# limitations under the License.

import json
import librosa
from pathlib import Path
from collections import Counter

Expand All @@ -40,6 +39,9 @@ def __init__(
pretrained_model: str,
output_lang_key: str,
device: str = None,
segment_duration: float = np.inf,
num_segments: int = 1,
random_seed: int = None,
**kwargs,
):
super().__init__(**kwargs)
Expand All @@ -54,6 +56,9 @@ def __init__(
self.pretrained_model = pretrained_model
self.device = device
self.output_lang_key = output_lang_key
self.segment_duration = segment_duration
self.num_segments = num_segments
self.random_seed = random_seed

if self.device is None:
if torch.cuda.is_available():
Expand All @@ -69,35 +74,62 @@ def process(self):

with Path(self.output_manifest_file).open('w') as f:
for item in tqdm(json_list):
pred_lang = self.segment(item["audio_filepath"], segment_duration=30, num_segments=3, random_seed=None)
pred_lang = self.get_label(item["audio_filepath"])
item[self.output_lang_key] = pred_lang
f.write(json.dumps(item, ensure_ascii=False) + '\n')


def segment(self, path2audio_file, segment_duration, num_segments, random_seed):
audio, sr = sf.read(path2audio_file)
def get_label(self, path2audio_file):
audio, sample_rate = sf.read(path2audio_file)
audio = np.float32(audio)

audio_length = audio.shape[0]

duration = sr * segment_duration
if duration > audio_length:
duration = audio_length
audio_segment_samples = sample_rate * self.segment_duration
segments_in_audio = int(audio_length / audio_segment_samples)

segment_starts = []
segment_ends = []

np.random.seed(self.random_seed)

if segments_in_audio <= 1:
segment_starts = [0]
segment_ends = [audio_length]
else:
if segments_in_audio > self.num_segments:
segments_in_audio = self.num_segments

long_segment_duration = int(audio_length / segments_in_audio)

for segment_no in range(segments_in_audio):
long_start_segment = long_segment_duration * segment_no
long_end_segment = long_segment_duration * (segment_no + 1)
segment_start = np.random.randint(long_start_segment, long_end_segment - audio_segment_samples)
segment_end = segment_start + audio_segment_samples
segment_starts.append(segment_start)
segment_ends.append(segment_end)


label_id_list = []
np.random.seed(random_seed)
starts = np.random.randint(0, audio_length - duration + 1, size=num_segments)
for start in starts:
audio_segm = audio[start : start + duration]
audio_segm = self.whisper.pad_or_trim(audio_segm)
mel = self.whisper.log_mel_spectrogram(audio_segm)

n_mels = 80

if self.pretrained_model = "large-v3":
n_mels=128

for segment_start, segment_end in zip(segment_starts, segment_ends):
audio_segement = audio[segment_start:segment_end]
audio_segement = self.whisper.pad_or_trim(audio_segement)
mel = self.whisper.log_mel_spectrogram(audio_segement, n_mels)
mel = mel.to(self.device)
_, probs = self.model.detect_language(mel)
lang = max(probs, key=probs.get)
label_id_list.append(lang)

m_label_id = Counter(label_id_list).most_common(1)[0][0]
return m_label_id


class ASRWhisper(BaseProcessor):
"""
Expand Down