Skip to content

Fix auto duration mode incorrectly clamping to 15 seconds#49

Merged
lmangani merged 5 commits intomainfrom
copilot/fix-audio-duration-issue
Feb 8, 2026
Merged

Fix auto duration mode incorrectly clamping to 15 seconds#49
lmangani merged 5 commits intomainfrom
copilot/fix-audio-duration-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 8, 2026

Auto duration mode (duration=-1) was being clamped to 15 seconds instead of allowing pipeline auto-detection (30-240s range). Root cause: max(15, min(240, -1)) evaluates to 15.

Changes

api/generate.py

  • Conditional clamping: only apply 15-240s range to positive values
  • Preserve -1/0 for auto-detection, normalize invalid negatives to -1

generate_ace.py

  • generate_track_ace: Allow -1/0 values for auto-detection
  • _run_ace_text2music: Preserve -1/0 for pipeline, validate negative inputs

docs/ACEFORGE_API.md

  • Document auto-detection behavior for duration parameter

Technical Detail

Before:

duration = max(15, min(240, duration))  # -1 → 15

After:

if duration > 0:
    duration = max(15, min(240, duration))  # Clamp positive values only
elif duration < 0 and duration != -1:
    duration = -1  # Normalize invalid negatives
# -1 and 0 pass through to pipeline auto-detection (30-240s)

The pipeline's existing auto-detection logic (cdmf_pipeline_ace_step.py:2047-2049) now receives -1 as intended and randomly selects duration in 30-240s range.

Original prompt

This section details on the original issue you should resolve

<issue_title>Only generating 14s audio</issue_title>
<issue_description>v1.0.8 is only generating 14s audio when auto is selected. I think there's an issue with clamping:
Note the "UI may send duration=-1 or 0; clamp to valid range (15–240s)"</issue_description>

<agent_instructions>verify the user claim about "auto" setting cropping the generation length/duration </agent_instructions>

Comments on the Issue (you are @copilot in this section)

@lmangani Hello @riversedge thanks for the report! I seem to be able to generate any lenght audio by using the time selector - could you confirm what other generation settings you used for this test?

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 8, 2026 09:14
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Co-authored-by: lmangani <1423657+lmangani@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix audio generation duration issue in auto mode Fix auto duration mode incorrectly clamping to 15 seconds Feb 8, 2026
Copilot AI requested a review from lmangani February 8, 2026 09:18
@lmangani lmangani marked this pull request as ready for review February 8, 2026 09:52
@lmangani lmangani merged commit c3a57f7 into main Feb 8, 2026
@lmangani lmangani deleted the copilot/fix-audio-duration-issue branch February 8, 2026 09:52
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.

Only generating 14s audio

2 participants