Skip to content

Make duration optional on text-to-music and text-to-sfx - #41

Merged
spencer-zqian merged 1 commit into
mainfrom
feat/optional-duration
Sep 15, 2026
Merged

spencer-zqian merged 1 commit into
mainfrom
feat/optional-duration

Conversation

@spencer-zqian

Copy link
Copy Markdown
Contributor

Follows the API change shipped on 2026-09-14: duration is optional on POST /v1/text-to-music and POST /v1/text-to-sfx, and text-to-sfx's minimum dropped from 1 second to 0.5.

What the API does with an absent duration

  • text-to-music infers the length from the prompt — or, when segments are given, uses the last segment's start plus 30 seconds.
  • text-to-sfx generates its own default length (8 seconds).

Neither is something the client can or should guess, so the only correct client behaviour is to leave the field out.

Changes

  • build_t2m_data, build_t2m_async_data and build_sfx_t2s_data omit duration when it is None. They previously built {"duration": str(duration)} unconditionally, so a None would have gone on the wire as the literal string "None".
  • duration is keyword-only on every resource method, so widening it to Optional[...] = None changes no call signature.
  • text-to-sfx's duration is now a float, not an int: the API's floor is 0.5 sec and the shortest effects run well under a second. str(0.5) already produced "0.5", which is covered by a regression test.
  • CLI: --duration is optional on text-to-music and text-to-sfx; the latter is type=float.

Versions

sonilo 0.17.0 → 0.18.0, sonilo-cli 0.16.0 → 0.17.0. The CLI's narrow core pin is widened to sonilo>=0.18.0,<0.19 in the same PR, and both pyproject.toml and _version.py are bumped on each package.

Tests

Four new cases in tests/test_requests.py — each builder omits an absent duration, and a fractional sfx duration survives as "0.5". Suites: 320 passed (core) and 167 passed (CLI).

The API resolves an omitted duration itself, so the client's job is to leave
the field out rather than invent a number:

* text-to-music infers the length from the prompt, or from `segments` when
  they are given (the last segment's start plus 30 seconds).
* text-to-sfx generates its own default length (8 seconds).

Both builders sent `duration` unconditionally, so passing None would have put
the literal string "None" on the wire; they now omit the field.

text-to-sfx's duration is also a float now, not an int: the API's minimum is
0.5 seconds, and the shortest effects -- a latch, a click, a single footstep --
run well under a second.

sonilo 0.17.0 -> 0.18.0, sonilo-cli 0.16.0 -> 0.17.0, with the CLI's narrow
core pin widened to match. `--duration` is optional on both CLI commands.
@lightsage-app

lightsage-app Bot commented Sep 15, 2026

Copy link
Copy Markdown

Lightsage docs evals

Waiting for the staging docs URL before running evals.

Lightsage will start the selected PR evals automatically when GitHub reports a successful docs deployment for this PR. This usually happens within 15 minutes.

Commit: 25b305b
Status: waiting for staging docs URL

@spencer-zqian
spencer-zqian merged commit afaa1c3 into main Sep 15, 2026
2 checks passed
@spencer-zqian
spencer-zqian deleted the feat/optional-duration branch September 15, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant