MCPcopy Create free account
hub / github.com/OpenMOSS/MOSS-TTS / build_example_rows

Function build_example_rows

clis/moss_voice_generator_app.py:36–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34
35
36def build_example_rows() -> list[tuple[str, str, str]]:
37 rows: list[tuple[str, int, str, str]] = []
38 with open(EXAMPLE_TEXTS_JSONL_PATH, "r", encoding="utf-8") as f:
39 for line in f:
40 if not line.strip():
41 continue
42 sample = json.loads(line)
43 parsed = _parse_example_id(sample.get("id", ""))
44 if parsed is None:
45 continue
46
47 language, index = parsed
48 instruction = str(sample.get("instruction", "")).strip()
49 text = str(sample.get("text", "")).strip()
50 rows.append((language, index, instruction, text))
51
52 language_order = {"zh": 0, "en": 1}
53 rows.sort(key=lambda item: (language_order.get(item[0], 99), item[1]))
54 return [(f"{language}/{index}", instruction, text) for language, index, instruction, text in rows]
55
56
57EXAMPLE_ROWS = build_example_rows()

Callers 1

Calls 2

_parse_example_idFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected