MCPcopy Create free account
hub / github.com/OpenMOSS/MOSS-TTSD / _load_single_audio

Function _load_single_audio

generation_utils.py:222–240  ·  view source on GitHub ↗

Load single audio, supports file path or (wav, sr) tuple Args: audio_input: String (file path) or tuple (wav, sr) Returns: tuple: (wav, sr)

(audio_input)

Source from the content-addressed store, hash-verified

220
221
222def _load_single_audio(audio_input):
223 """Load single audio, supports file path or (wav, sr) tuple
224
225 Args:
226 audio_input: String (file path) or tuple (wav, sr)
227
228 Returns:
229 tuple: (wav, sr)
230 """
231 if isinstance(audio_input, tuple) and len(audio_input) == 2:
232 # Already a (wav, sr) tuple
233 wav, sr = audio_input
234 return wav, sr
235 elif isinstance(audio_input, str):
236 # Is a file path, needs to be loaded
237 wav, sr = torchaudio.load(audio_input)
238 return wav, sr
239 else:
240 raise ValueError(f"Unsupported audio input format: {type(audio_input)}")
241
242
243def merge_speaker_audios(wav1, sr1, wav2, sr2, target_sample_rate=16000):

Callers 1

load_audio_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected