MCPcopy Create free account
hub / github.com/modelscope/FunASR / audio_duration_seconds

Function audio_duration_seconds

examples/migration/benchmark_funasr.py:92–111  ·  view source on GitHub ↗
(path: Path)

Source from the content-addressed store, hash-verified

90
91
92def audio_duration_seconds(path: Path) -> Optional[float]:
93 try:
94 import soundfile as sf
95
96 info = sf.info(str(path))
97 if info.samplerate:
98 return float(info.frames) / float(info.samplerate)
99 except Exception:
100 pass
101
102 if path.suffix.lower() == ".wav":
103 try:
104 with wave.open(str(path), "rb") as wav_file:
105 frames = wav_file.getnframes()
106 rate = wav_file.getframerate()
107 if rate:
108 return float(frames) / float(rate)
109 except Exception:
110 return None
111 return None
112
113
114def metadata_dict(items: Iterable[str]) -> Dict[str, str]:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…