MCPcopy Create free account
hub / github.com/FunAudioLLM/Fun-Audio-Chat / load_audio_batch_default

Function load_audio_batch_default

training/plugin/mm_plugins.py:45–73  ·  view source on GitHub ↗

Default audio loader using librosa. Args: paths: List of audio file paths sampling_rate: Target sampling rate Returns: List of audio arrays

(paths: list[str], sampling_rate: int)

Source from the content-addressed store, hash-verified

43
44
45def load_audio_batch_default(paths: list[str], sampling_rate: int) -> list[np.ndarray]:
46 """
47 Default audio loader using librosa.
48
49 Args:
50 paths: List of audio file paths
51 sampling_rate: Target sampling rate
52
53 Returns:
54 List of audio arrays
55 """
56 try:
57 import librosa
58 except ImportError:
59 raise ImportError("librosa is required for audio loading. Install with: pip install librosa")
60
61 audios = []
62 for path in paths:
63 if not path:
64 audios.append(np.array([]))
65 continue
66 try:
67 audio, sr = librosa.load(path, sr=sampling_rate, mono=True)
68 audios.append(audio)
69 except Exception as e:
70 logger.warning(f"Failed to load audio from {path}: {e}")
71 audios.append(np.array([]))
72
73 return audios
74
75
76@dataclass

Callers 1

load_audio_batchMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected