Spaces:
Running
Running
Download frontend/src/utils/format.js from Falln87/OmniVoice-Studio: direct link, hf CLI and curl.
- Browser
- Download file 537 Bytes
-
https://huggingface.co/spaces/Falln87/OmniVoice-Studio/resolve/main/frontend/src/utils/format.js
- Command line
-
hf download hf://spaces/Falln87/OmniVoice-Studio/frontend/src/utils/format.js
-
curl -L -o format.js https://huggingface.co/spaces/Falln87/OmniVoice-Studio/resolve/main/frontend/src/utils/format.js
537 Bytes
| export function formatTime(s) { | |
| const m = Math.floor(s / 60); | |
| const sec = (s % 60).toFixed(1); | |
| return `${m}:${sec.padStart(4, '0')}`; | |
| } | |
| export async function probeAudioDuration(file) { | |
| return new Promise((resolve) => { | |
| const url = URL.createObjectURL(file); | |
| const a = new Audio(); | |
| const done = (v) => { URL.revokeObjectURL(url); resolve(v); }; | |
| a.addEventListener('loadedmetadata', () => done(isFinite(a.duration) ? a.duration : null)); | |
| a.addEventListener('error', () => done(null)); | |
| a.src = url; | |
| }); | |
| } | |