Add files using upload-large-folder tool
Browse files- .gitattributes +2 -0
- audios.tar.gz +3 -0
- compress_audios_tar_gz.py +95 -0
- copy_audio_and_rewrite_jsonl.py +95 -0
- lora_0311_10w+55w+noise_nost_error_train90_with_domain_100k_sample.jsonl +3 -0
- lora_0311_10w+55w+noise_nost_error_train90_with_domain_100k_sample_rewritten.jsonl +3 -0
- sample_jsonl_first_n.py +31 -0
.gitattributes
CHANGED
|
@@ -58,3 +58,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
lora_0311_10w+55w+noise_nost_error_train90_with_domain_100k_sample_rewritten.jsonl filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
lora_0311_10w+55w+noise_nost_error_train90_with_domain_100k_sample.jsonl filter=lfs diff=lfs merge=lfs -text
|
audios.tar.gz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8f910ebf0b29b6fd4674c71502c10ebe2873a6dcdde405eff4ffb8ff4e28e305
|
| 3 |
+
size 39108130317
|
compress_audios_tar_gz.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import argparse
|
| 3 |
+
import gzip
|
| 4 |
+
import subprocess
|
| 5 |
+
from concurrent.futures import FIRST_COMPLETED, ProcessPoolExecutor, wait
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
DEFAULT_WORKERS = 32
|
| 10 |
+
DEFAULT_CHUNK_MB = 32
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def gzip_chunk(data: bytes, compresslevel: int) -> bytes:
|
| 14 |
+
return gzip.compress(data, compresslevel=compresslevel, mtime=0)
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def stream_tar_gz_parallel(
|
| 18 |
+
input_dir: Path,
|
| 19 |
+
output_file: Path,
|
| 20 |
+
workers: int,
|
| 21 |
+
chunk_size: int,
|
| 22 |
+
compresslevel: int,
|
| 23 |
+
) -> None:
|
| 24 |
+
tar_cmd = ["tar", "-cf", "-", "-C", str(input_dir.parent), input_dir.name]
|
| 25 |
+
tar_proc = subprocess.Popen(tar_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
| 26 |
+
if tar_proc.stdout is None or tar_proc.stderr is None:
|
| 27 |
+
raise RuntimeError("Failed to start tar process")
|
| 28 |
+
|
| 29 |
+
pending = {}
|
| 30 |
+
completed = {}
|
| 31 |
+
next_index = 0
|
| 32 |
+
next_to_write = 0
|
| 33 |
+
max_in_flight = max(workers * 2, 1)
|
| 34 |
+
|
| 35 |
+
with output_file.open("wb") as out_f, ProcessPoolExecutor(max_workers=workers) as executor:
|
| 36 |
+
try:
|
| 37 |
+
while True:
|
| 38 |
+
while len(pending) < max_in_flight:
|
| 39 |
+
chunk = tar_proc.stdout.read(chunk_size)
|
| 40 |
+
if not chunk:
|
| 41 |
+
break
|
| 42 |
+
future = executor.submit(gzip_chunk, chunk, compresslevel)
|
| 43 |
+
pending[future] = next_index
|
| 44 |
+
next_index += 1
|
| 45 |
+
|
| 46 |
+
if not pending:
|
| 47 |
+
break
|
| 48 |
+
|
| 49 |
+
done, _ = wait(pending, return_when=FIRST_COMPLETED)
|
| 50 |
+
for future in done:
|
| 51 |
+
completed[pending.pop(future)] = future.result()
|
| 52 |
+
|
| 53 |
+
while next_to_write in completed:
|
| 54 |
+
out_f.write(completed.pop(next_to_write))
|
| 55 |
+
next_to_write += 1
|
| 56 |
+
finally:
|
| 57 |
+
tar_proc.stdout.close()
|
| 58 |
+
|
| 59 |
+
stderr = tar_proc.stderr.read().decode("utf-8", errors="replace").strip()
|
| 60 |
+
tar_proc.stderr.close()
|
| 61 |
+
return_code = tar_proc.wait()
|
| 62 |
+
if return_code != 0:
|
| 63 |
+
raise RuntimeError(f"tar failed with exit code {return_code}: {stderr}")
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def main() -> None:
|
| 67 |
+
parser = argparse.ArgumentParser(description="Compress a directory into tar.gz with parallel gzip workers.")
|
| 68 |
+
parser.add_argument("--input-dir", required=True, help="Directory to compress.")
|
| 69 |
+
parser.add_argument("--output", required=True, help="Output tar.gz file path.")
|
| 70 |
+
parser.add_argument("--workers", type=int, default=DEFAULT_WORKERS, help="Number of gzip worker processes.")
|
| 71 |
+
parser.add_argument("--chunk-mb", type=int, default=DEFAULT_CHUNK_MB, help="Chunk size in MB.")
|
| 72 |
+
parser.add_argument("--compresslevel", type=int, default=6, help="Gzip level from 0 to 9.")
|
| 73 |
+
args = parser.parse_args()
|
| 74 |
+
|
| 75 |
+
input_dir = Path(args.input_dir).resolve()
|
| 76 |
+
output_file = Path(args.output).resolve()
|
| 77 |
+
|
| 78 |
+
if not input_dir.exists():
|
| 79 |
+
raise FileNotFoundError(f"Input directory not found: {input_dir}")
|
| 80 |
+
if not input_dir.is_dir():
|
| 81 |
+
raise NotADirectoryError(f"Input path is not a directory: {input_dir}")
|
| 82 |
+
|
| 83 |
+
output_file.parent.mkdir(parents=True, exist_ok=True)
|
| 84 |
+
stream_tar_gz_parallel(
|
| 85 |
+
input_dir=input_dir,
|
| 86 |
+
output_file=output_file,
|
| 87 |
+
workers=args.workers,
|
| 88 |
+
chunk_size=args.chunk_mb * 1024 * 1024,
|
| 89 |
+
compresslevel=args.compresslevel,
|
| 90 |
+
)
|
| 91 |
+
print(f"Created archive: {output_file}")
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
if __name__ == "__main__":
|
| 95 |
+
main()
|
copy_audio_and_rewrite_jsonl.py
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import argparse
|
| 3 |
+
import json
|
| 4 |
+
import shutil
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def build_target_path(audio_path: Path, audio_root: Path) -> Path:
|
| 9 |
+
if audio_path.is_absolute():
|
| 10 |
+
relative_path = audio_path.relative_to("/")
|
| 11 |
+
else:
|
| 12 |
+
relative_path = audio_path
|
| 13 |
+
return audio_root / relative_path
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def copy_audio(audio_path: Path, audio_root: Path, copied: dict[str, Path]) -> Path:
|
| 17 |
+
key = str(audio_path)
|
| 18 |
+
if key in copied:
|
| 19 |
+
return copied[key]
|
| 20 |
+
if not audio_path.exists():
|
| 21 |
+
raise FileNotFoundError(f"Audio file not found: {audio_path}")
|
| 22 |
+
|
| 23 |
+
target_path = build_target_path(audio_path, audio_root)
|
| 24 |
+
target_path.parent.mkdir(parents=True, exist_ok=True)
|
| 25 |
+
shutil.copy2(audio_path, target_path)
|
| 26 |
+
copied[key] = target_path
|
| 27 |
+
return target_path
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def rewrite_record(item: dict, audio_root: Path, copied: dict[str, Path], input_path: Path, line_no: int) -> int:
|
| 31 |
+
rewritten = 0
|
| 32 |
+
|
| 33 |
+
if "audio" in item:
|
| 34 |
+
audio_path = Path(item["audio"])
|
| 35 |
+
item["audio"] = str(copy_audio(audio_path, audio_root, copied))
|
| 36 |
+
rewritten += 1
|
| 37 |
+
|
| 38 |
+
if "audios" in item:
|
| 39 |
+
audios = item["audios"]
|
| 40 |
+
if not isinstance(audios, list):
|
| 41 |
+
raise ValueError(f"{input_path}:{line_no} field 'audios' is not a list")
|
| 42 |
+
item["audios"] = [str(copy_audio(Path(audio), audio_root, copied)) for audio in audios]
|
| 43 |
+
rewritten += len(item["audios"])
|
| 44 |
+
|
| 45 |
+
if rewritten == 0:
|
| 46 |
+
raise ValueError(f"{input_path}:{line_no} has neither 'audio' nor 'audios'")
|
| 47 |
+
|
| 48 |
+
return rewritten
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def process_jsonl(input_path: Path, output_path: Path, audio_root: Path) -> tuple[int, int, int]:
|
| 52 |
+
copied: dict[str, Path] = {}
|
| 53 |
+
line_count = 0
|
| 54 |
+
audio_refs = 0
|
| 55 |
+
|
| 56 |
+
with input_path.open("r", encoding="utf-8") as src, output_path.open("w", encoding="utf-8") as dst:
|
| 57 |
+
for line_no, line in enumerate(src, start=1):
|
| 58 |
+
if not line.strip():
|
| 59 |
+
continue
|
| 60 |
+
|
| 61 |
+
item = json.loads(line)
|
| 62 |
+
audio_refs += rewrite_record(item, audio_root, copied, input_path, line_no)
|
| 63 |
+
dst.write(json.dumps(item, ensure_ascii=False) + "\n")
|
| 64 |
+
line_count += 1
|
| 65 |
+
|
| 66 |
+
return line_count, audio_refs, len(copied)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def main() -> None:
|
| 70 |
+
parser = argparse.ArgumentParser(description="Copy referenced audio files and rewrite JSONL audio paths.")
|
| 71 |
+
parser.add_argument("--input", required=True, help="Input JSONL file.")
|
| 72 |
+
parser.add_argument("--output", required=True, help="Output rewritten JSONL file.")
|
| 73 |
+
parser.add_argument("--audio-root", required=True, help="Destination root for copied audio files.")
|
| 74 |
+
args = parser.parse_args()
|
| 75 |
+
|
| 76 |
+
input_path = Path(args.input).resolve()
|
| 77 |
+
output_path = Path(args.output).resolve()
|
| 78 |
+
audio_root = Path(args.audio_root).resolve()
|
| 79 |
+
|
| 80 |
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
| 81 |
+
audio_root.mkdir(parents=True, exist_ok=True)
|
| 82 |
+
|
| 83 |
+
line_count, audio_refs, unique_audio_count = process_jsonl(
|
| 84 |
+
input_path=input_path,
|
| 85 |
+
output_path=output_path,
|
| 86 |
+
audio_root=audio_root,
|
| 87 |
+
)
|
| 88 |
+
print(
|
| 89 |
+
f"Processed {line_count} lines, rewrote {audio_refs} audio references, "
|
| 90 |
+
f"copied {unique_audio_count} unique audio files"
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
if __name__ == "__main__":
|
| 95 |
+
main()
|
lora_0311_10w+55w+noise_nost_error_train90_with_domain_100k_sample.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b1c456b52ba754c284718603a727cb6f4659fbd062014898032ecd7395b8e8d4
|
| 3 |
+
size 44323395
|
lora_0311_10w+55w+noise_nost_error_train90_with_domain_100k_sample_rewritten.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:39f41850c9b03b3f0a997821c51f0089e779e71eadb41ec86596ec0dd703b892
|
| 3 |
+
size 48423395
|
sample_jsonl_first_n.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import argparse
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
def main() -> None:
|
| 7 |
+
parser = argparse.ArgumentParser(description="Write the first N non-empty JSONL lines to a new file.")
|
| 8 |
+
parser.add_argument("--input", required=True, help="Input JSONL file.")
|
| 9 |
+
parser.add_argument("--output", required=True, help="Output JSONL file.")
|
| 10 |
+
parser.add_argument("--limit", type=int, default=100000, help="Number of non-empty lines to keep.")
|
| 11 |
+
args = parser.parse_args()
|
| 12 |
+
|
| 13 |
+
input_path = Path(args.input).resolve()
|
| 14 |
+
output_path = Path(args.output).resolve()
|
| 15 |
+
output_path.parent.mkdir(parents=True, exist_ok=True)
|
| 16 |
+
|
| 17 |
+
kept = 0
|
| 18 |
+
with input_path.open("r", encoding="utf-8") as src, output_path.open("w", encoding="utf-8") as dst:
|
| 19 |
+
for line in src:
|
| 20 |
+
if not line.strip():
|
| 21 |
+
continue
|
| 22 |
+
dst.write(line)
|
| 23 |
+
kept += 1
|
| 24 |
+
if kept >= args.limit:
|
| 25 |
+
break
|
| 26 |
+
|
| 27 |
+
print(f"Wrote {kept} lines to {output_path}")
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
if __name__ == "__main__":
|
| 31 |
+
main()
|