Menu

A Duration Target Is Not a Validation Rule for Generated Audio
📰

A Duration Target Is Not a Validation Rule for Generated Audio

DEV Community: typescript·Sophia Chen·14 days ago
#OcwaQXa8
#devtotypescript#devto#dev#result#delivery
Reading 0:00
15s threshold

A requested duration tells a generator what to aim for. The finished file tells a player what it can actually play. Keeping those two facts separate makes a creative interface easier to understand.

Consider a form for a short musical introduction. Someone selects 15 seconds, then receives a playable result lasting 18.4 seconds. Should the application reject it as invalid?

That depends on the contract. If 15 seconds is a creative preference, the result may be useful. If a delivery system accepts only files of exactly 15 seconds, the same file is not ready for delivery. One number cannot represent both conditions.

Keep the request and the measurement separate

This small TypeScript model is an illustrative design, not a description of a particular production backend:

type AudioResult = { requestedTargetSeconds : number ; measuredDurationSeconds : number | null ; durationStatus : " not-measured " | " measured " ; };

function durationSummary ( result : AudioResult ): string { if ( result .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.