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

Function attach_reference_audio_codes

moss_tts_delay/finetuning/prepare_data.py:129–149  ·  view source on GitHub ↗
(
    records: List[Dict[str, Any]],
    path_to_codes: Dict[str, List[List[int]]],
)

Source from the content-addressed store, hash-verified

127
128
129def attach_reference_audio_codes(
130 records: List[Dict[str, Any]],
131 path_to_codes: Dict[str, List[List[int]]],
132) -> None:
133 for record in records:
134 ref_audio = normalize_audio_path_list(record.get("ref_audio"), "ref_audio")
135 if ref_audio is not None:
136 if len(ref_audio) != 1:
137 raise ValueError("`ref_audio` only supports a single path.")
138 record["ref_audio_codes"] = path_to_codes[ref_audio[0]]
139
140 reference_audio = normalize_audio_path_list(record.get("reference_audio"), "reference_audio")
141 if reference_audio is not None:
142 record["reference_audio_codes"] = [path_to_codes[path] for path in reference_audio]
143
144 reference = normalize_audio_path_list(record.get("reference"), "reference", allow_none=True)
145 if reference is not None:
146 record["reference_audio_codes"] = [
147 None if path is None else path_to_codes[path]
148 for path in reference
149 ]
150
151
152def main() -> None:

Callers 1

mainFunction · 0.70

Calls 2

getMethod · 0.45

Tested by

no test coverage detected