Skip to content

This PR resolves a critical runtime crash during the audio export stage on Linux systems, specifically occurring in Cloud environments like Lightning AI.#1089

Open
sobiswriter wants to merge 8 commits intoace-step:mainfrom
sobiswriter:fix/audio-export-linux
Open

This PR resolves a critical runtime crash during the audio export stage on Linux systems, specifically occurring in Cloud environments like Lightning AI.#1089
sobiswriter wants to merge 8 commits intoace-step:mainfrom
sobiswriter:fix/audio-export-linux

Conversation

@sobiswriter
Copy link
Copy Markdown

@sobiswriter sobiswriter commented Apr 11, 2026

##The Problem
In environments using PyTorch 2.10.0+cu128, the torchcodec library fails with a binary incompatibility error: undefined symbol: torch_dtype_float4_e2m1fn_x2. Additionally, many cloud instances lack the specific shared objects (like libavutil.so.60) required by the experimental MP3 export path, causing an OSError.

specific error:
raise RuntimeError(
RuntimeError: Could not load libtorchcodec. Likely causes:
1. FFmpeg is not properly installed in your environment. We support
versions 4, 5, 6, 7, and 8, and we attempt to load libtorchcodec
for each of those versions. Errors for versions not installed on
your system are expected; only the error for your installed FFmpeg
version is relevant. On Windows, ensure you've installed the
"full-shared" version which ships DLLs.
2. The PyTorch version (2.10.0+cu128) is not compatible with
this version of TorchCodec. Refer to the version compatibility
table:
https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
3. Another runtime dependency; see exceptions below.

    The following exceptions were raised as we tried to load libtorchcodec:

[start of libtorchcodec loading traceback]

##Changes
Backend Stabilization: Patched acestep/audio_utils.py to prioritize FLAC as the default export format. This bypasses the unstable torchcodec MP3 logic while preserving lossless audio quality.
Library Path Resolution: Added LD_LIBRARY_PATH initialization at the module level to help the system locate FFmpeg shared libraries in standard Linux paths.
Documentation: Updated INSTALL.md with the necessary apt-get command for Linux users to install missing system-level FFmpeg dependencies.
##Verification
Environment: Lightning AI (L4 GPU), Ubuntu 22.04.
Success: Audio generation now completes and serializes successfully without crashing at the final stage.

Summary by CodeRabbit

  • New Features

    • Added ACESTEP_FORCE_FLAC_EXPORT env var to optionally force FLAC audio exports.
  • Bug Fixes

    • Improved audio export reliability for non‑MP3 formats and cloud GPU environments; respects caller channel layout.
  • Documentation

    • Added Cloud GPU install and troubleshooting guidance (required packages and LD_LIBRARY_PATH note) to prevent audio export failures.

… ai.

- Patched acestep/audio_utils.py to force FLAC as default export format.
- Injected LD_LIBRARY_PATH to resolve FFmpeg library discovery issues.
- Fixed symbol errors in PyTorch 2.10+ and updated INSTALL.md.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

AudioSaver.save_audio now checks ACESTEP_FORCE_FLAC_EXPORT at call time and forces format="flac" when set; it also preserves the caller-provided channels_first instead of forcing True. Docs add Cloud-GPU package and LD_LIBRARY_PATH guidance; .env.example documents ACESTEP_FORCE_FLAC_EXPORT.

Changes

Cohort / File(s) Summary
Audio export logic
acestep/audio_utils.py
Reads ACESTEP_FORCE_FLAC_EXPORT at save time and overrides format="flac" when set; uses caller channels_first instead of forcing True; keeps existing format branches and adds a commented backend="soundfile" hint.
Installation docs
docs/en/INSTALL.md
Adds an IMPORTANT Cloud-GPU callout instructing installation of system packages (ffmpeg, libavdevice60, libavcodec-extra) and suggests exporting LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH in the same shell to avoid audio export crashes.
Environment example
.env.example
Adds commented ACESTEP_FORCE_FLAC_EXPORT entry to document optional forcing of FLAC exports as a workaround for some cloud GPU environments.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Caller (UI / Code)
    participant Env as OS Env
    participant AudioSaver as AudioSaver.save_audio
    participant Torchaudio as torchaudio / backend

    Caller->>AudioSaver: request save_audio(buffer, format, channels_first)
    Env->>AudioSaver: ACESTEP_FORCE_FLAC_EXPORT present?
    alt ACESTEP_FORCE_FLAC_EXPORT == "1"
        AudioSaver->>AudioSaver: override format = "flac"
    end
    AudioSaver->>Torchaudio: save(buffer, format, channels_first)
    Torchaudio-->>AudioSaver: success / error
    AudioSaver-->>Caller: return result / raise
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • ChuxiJ

Poem

"I hopped through code at morning's call,
FLAC now rescues exports for all,
Channels heed the caller's plea,
Docs and env keep crashes free.
🐰🎵"

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: resolving a critical audio export crash on Linux systems in Cloud environments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
acestep/audio_utils.py (1)

310-318: Dead code: else branch is unreachable.

All valid format values are handled by the preceding branches:

  • "mp3" → line 266
  • "opus", "aac" → line 275
  • "flac", "wav", "wav32" → line 284

Since the format validation on lines 223-225 already normalizes invalid formats to self.default_format (which must be one of the valid formats), this else branch can never execute.

🧹 Remove unreachable code
             torchaudio.save(
                 str(output_path),
                 audio_tensor,
                 sample_rate,
                 channels_first=True,
                 backend='soundfile',
             )
-        else:
-            # Other formats use default backend
-            torchaudio.save(
-                str(output_path),
-                audio_tensor,
-                sample_rate,
-                channels_first=channels_first,
-                backend="soundfile"  # <--- ADD THIS LINE
-            )
-
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@acestep/audio_utils.py` around lines 310 - 318, Remove the unreachable else
branch that calls torchaudio.save(...) with backend="soundfile" in the audio
saving logic: the format cases ("mp3", "opus"/"aac", "flac"/"wav"/"wav32") and
the prior normalization to self.default_format already cover all valid formats,
so delete the entire else block (the torchaudio.save call with
backend="soundfile") from the function containing the audio save logic to
eliminate dead code; if you intended a default backend, instead set it where
formats are normalized or in the relevant format-specific branches (refer to the
existing format-handling branches around the torchaudio.save calls).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@acestep/audio_utils.py`:
- Line 26: The module acquires an unused import `sys` which should be removed to
avoid lint warnings; delete the `import sys` statement from the top of
acestep/audio_utils.py unless you actually need `sys` for a platform check—if
you do need it, move the usage into the platform-checking codepath and reference
`sys` there instead of leaving the unused import.
- Around line 222-225: The code currently overwrites the caller-supplied format
by unconditionally setting format = "flac"; remove that hardcoded assignment so
the function respects the incoming format parameter, only falling back to
self.default_format when format is None or empty (e.g., format = format or
self.default_format). Keep the validation check and logger.warning for
unsupported values (use the same logger.warning call that references
self.default_format), and if you need an opt-in forced-FLAC behavior implement
it via an environment variable or constructor flag rather than overwriting the
parameter; check places that call this function (inference.py and
generation_progress.py) still pass their audio_format through.
- Around line 14-16: The module-level hardcoded LD_LIBRARY_PATH assignment
should be removed and replaced with a guarded, platform-aware initialization
that runs early (before any audio libs are imported) — implement a helper (e.g.,
init_ffmpeg_ld_library_path) and call it from your application entrypoint or
package __init__.py before importing torchaudio/soundfile; in that helper check
platform.machine()/sys.platform and append the appropriate path
("/usr/lib/x86_64-linux-gnu" or "/usr/lib/aarch64-linux-gnu") only if not
already present, and avoid touching LD_LIBRARY_PATH on non-Linux platforms so
you don’t pollute other OS environments or rely on import-time side effects.

In `@docs/en/INSTALL.md`:
- Around line 137-144: Remove the internal implementation notes currently
inserted into the user-facing INSTALL.md (the lines mentioning "In
acestep/audio_utils.py", os.environ["LD_LIBRARY_PATH"], save_audio,
torchaudio.save and backend="soundfile") and replace them with the intended bash
snippet only; also close or remove the empty ```bash code block so the Linux
launch scripts section flows into the Git installation note and keep the
IMPORTANT cloud-user note intact. Ensure no references to code symbols
(os.environ, save_audio, torchaudio.save) remain in the user guide—keep only
actionable install commands and notes.

---

Nitpick comments:
In `@acestep/audio_utils.py`:
- Around line 310-318: Remove the unreachable else branch that calls
torchaudio.save(...) with backend="soundfile" in the audio saving logic: the
format cases ("mp3", "opus"/"aac", "flac"/"wav"/"wav32") and the prior
normalization to self.default_format already cover all valid formats, so delete
the entire else block (the torchaudio.save call with backend="soundfile") from
the function containing the audio save logic to eliminate dead code; if you
intended a default backend, instead set it where formats are normalized or in
the relevant format-specific branches (refer to the existing format-handling
branches around the torchaudio.save calls).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c9564f65-145f-4abf-8b5f-c5f550e642ad

📥 Commits

Reviewing files that changed from the base of the PR and between 82252c2 and ed95f0e.

📒 Files selected for processing (2)
  • acestep/audio_utils.py
  • docs/en/INSTALL.md

Comment thread acestep/audio_utils.py Outdated
Comment thread acestep/audio_utils.py Outdated
Comment thread acestep/audio_utils.py Outdated
Comment thread docs/en/INSTALL.md Outdated
@ChuxiJ
Copy link
Copy Markdown
Contributor

ChuxiJ commented Apr 13, 2026

Thanks for tackling this — the torchcodec/Lightning AI cloud-GPU pain is real and worth fixing. However, I went through the diff carefully and I think this PR can't be merged as-is. There are two functional blockers plus a broken docs block. I verified every finding against current main before writing this.

🔴 Blocker 1 — format = "flac" hardcode silently destroys format selection

acestep/audio_utils.py:222 replaces

format = (format or self.default_format).lower()

with

format = "flac"

This unconditionally overrides whatever the caller passes. Combined with the suffix-preservation logic at L229-236 (which keeps .mp3/.opus/.aac/.m4a paths untouched because those extensions are on the allow-list), the outcome is worse than just "always FLAC":

A user requests output.mp3 → the file is written with FLAC-encoded bytes but keeps the .mp3 extension. Downstream players will fail or decode garbage. Extension and content are out of sync.

Any user of the Gradio UI who picks MP3/WAV/Opus/AAC will hit this.

🔴 Blocker 2 — The backend="soundfile" change is in a dead branch

I think this is worth flagging because it means the PR's intended fix isn't actually running on any real code path:

  • format == "mp3" → goes through _save_mp3() (L263)
  • format in ("opus", "aac") → explicit backend='ffmpeg' (L273)
  • format in ("flac", "wav", "wav32")already has backend='soundfile' on main (L304)
  • The else: branch at L307-313 (where this PR adds backend="soundfile") is unreachable, because format is normalized to one of the six valid values at L218-221

So the only reason this PR "fixes" torchcodec at runtime is Blocker 1 — forcing format = "flac" routes everything into the flac branch that was already using soundfile on main. The else-branch edit itself is a no-op (CodeRabbit also flagged this as dead code).

🔴 Blocker 3 — Module-level LD_LIBRARY_PATH assignment

acestep/audio_utils.py:14:

os.environ["LD_LIBRARY_PATH"] = "/usr/lib/x86_64-linux-gnu:" + os.environ.get("LD_LIBRARY_PATH", "")

Problems:

  1. Hardcoded to x86_64-linux-gnu. On Linux ARM64 (Jetson, Graviton, AWS Ampere) this injects a path that doesn't exist and can mask the correct one. On macOS/Windows the env var is meaningless (macOS uses DYLD_LIBRARY_PATH).
  2. Runs at module import time, which is too late — by the time audio_utils is imported, the dynamic linker may have already resolved symbols for earlier-imported libs (torch, torchaudio, torchcodec). Changing LD_LIBRARY_PATH inside a running process does not re-trigger ld.so lookups for already-loaded .so files.
  3. Import-time side effects on os.environ are a footgun for anyone importing this module.

Recommended: remove this line entirely and instead document in INSTALL.md that Lightning AI / Lambda users should export LD_LIBRARY_PATH=... before launching start_gradio_ui.sh / start_api_server.sh. That's the only place the setting can actually influence the linker.

🟠 Blocker 4 — docs/en/INSTALL.md fenced code block is broken

The diff removes the closing ``` on L129 (which terminates the Linux launch-script bash block) and then at the end opens a new ```bash that is never closed. The pre-existing > **Note:** Git must be installed... gets swallowed into the unterminated code block, and the raw implementation-notes paragraph in the middle ("In acestep/audio_utils.py: Added os.environ...") should not live in user-facing install docs at all — it reads as internal commit-message text.

🟡 Nit — Unused import sys

acestep/audio_utils.py:26 adds import sys but the symbol is never referenced.


Suggested fix list

  1. Remove the format = "flac" override. Restore format = (format or self.default_format).lower(). If you want a way to force FLAC as a torchcodec workaround, make it opt-in via an env var (e.g. ACESTEP_FORCE_FLAC_EXPORT=1) that callers/docs can set — do not silently mutate the caller's choice.
  2. Drop the else-branch edit. It's dead code on main, and the useful backends are already set correctly on the real branches.
  3. Delete the module-level os.environ["LD_LIBRARY_PATH"] assignment. Move the guidance to INSTALL.md as an export the user runs in their shell before launching the app.
  4. Fix the INSTALL.md fenced-block structure. Close the Linux launch bash block properly, remove the "In acestep/audio_utils.py: …" implementation paragraph, and don't open a trailing unterminated ```bash at the end.
  5. Remove import sys.

Happy to help review a revised version. The underlying direction — helping cloud-GPU users avoid the torchcodec load failure — is genuinely useful; it just needs to not break format selection or pollute os.environ at import time to get there.

- Restore original format selection logic and add optional FLAC override via ACESTEP_FORCE_FLAC_EXPORT env var
- Remove ineffective backend change in unreachable branch
- Remove module-level LD_LIBRARY_PATH modification
- Update INSTALL.md with proper FFmpeg dependency setup and environment variable guidance
- Fix broken markdown code blocks in documentation
- Remove unused import

This keeps user format choice intact while providing a safe workaround for torchcodec issues in cloud environments.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.env.example:
- Line 52: Change the default for ACESTEP_FORCE_FLAC_EXPORT in the sample env so
forced FLAC is opt-in: update the ACESTEP_FORCE_FLAC_EXPORT entry to a disabled
state (e.g., set to 0 or comment out the line) instead of 1 and add a short
inline comment noting that enabling it is optional/experimental; ensure the
variable name ACESTEP_FORCE_FLAC_EXPORT is preserved so consumers can opt in if
needed.

In `@acestep/audio_utils.py`:
- Around line 220-222: The current force_flac branch sets format = "flac" but
leaves output_path's filename/extension unchanged, causing extension/content
mismatches; when ACESTEP_FORCE_FLAC_EXPORT is "1" (force_flac), update
output_path to match the forced format (e.g., use
pathlib.Path(output_path).with_suffix(f".{format}") or rebuild the filename from
format) and ensure any downstream suffix normalization logic (the block around
output_path and its suffix handling) uses the updated format so saved bytes and
file extension are consistent; reference the force_flac variable, format
assignment, and output_path handling in your change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1e533094-2683-4d7e-a791-0c91cf16c374

📥 Commits

Reviewing files that changed from the base of the PR and between ed95f0e and 0457406.

📒 Files selected for processing (3)
  • .env.example
  • acestep/audio_utils.py
  • docs/en/INSTALL.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/en/INSTALL.md

Comment thread .env.example Outdated
Comment thread acestep/audio_utils.py
Comment on lines +220 to +222
force_flac = os.getenv("ACESTEP_FORCE_FLAC_EXPORT", "0") == "1"
if force_flac:
format = "flac"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Forced FLAC can produce extension/content mismatch (e.g., .mp3 file containing FLAC).

At Line 221, format is forced to "flac", but if output_path already has .mp3/.wav (Line 233), suffix normalization won’t rewrite it. With upstream callers prebuilding names from requested format, this can save FLAC bytes under non-FLAC extensions.

Proposed fix
         force_flac = os.getenv("ACESTEP_FORCE_FLAC_EXPORT", "0") == "1"
         if force_flac:
-            format = "flac" 
+            format = "flac"

         # Ensure output path has correct extension
         output_path = Path(output_path)
+        if force_flac and output_path.suffix.lower() != ".flac":
+            output_path = output_path.with_suffix(".flac")

Also applies to: 228-240

🧰 Tools
🪛 Ruff (0.15.9)

[error] 222-222: Variable format is shadowing a Python builtin

(A001)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@acestep/audio_utils.py` around lines 220 - 222, The current force_flac branch
sets format = "flac" but leaves output_path's filename/extension unchanged,
causing extension/content mismatches; when ACESTEP_FORCE_FLAC_EXPORT is "1"
(force_flac), update output_path to match the forced format (e.g., use
pathlib.Path(output_path).with_suffix(f".{format}") or rebuild the filename from
format) and ensure any downstream suffix normalization logic (the block around
output_path and its suffix handling) uses the updated format so saved bytes and
file extension are consistent; reference the force_flac variable, format
assignment, and output_path handling in your change.

@sobiswriter
Copy link
Copy Markdown
Author

Hello,
Thanks for the detailed review, this is the actually my first time contributing to a big project like this — I’ve addressed all the concerns raised and updated the PR accordingly.

Changes made

1. Restored format selection logic

  • Reverted the hardcoded format = "flac" change.
  • Restored format = (format or self.default_format).lower() to preserve user intent.
  • Introduced an opt-in workaround via environment variable:
    ACESTEP_FORCE_FLAC_EXPORT=1
    This allows users in problematic environments (e.g., torchcodec incompatibility) to force FLAC export without affecting default behavior.

2. Removed ineffective backend modification

  • Dropped the backend="soundfile" change in the else branch, as it is unreachable on current main.
  • Existing valid branches already use appropriate backends.

3. Removed module-level LD_LIBRARY_PATH modification

  • Deleted the os.environ["LD_LIBRARY_PATH"] assignment from audio_utils.py.
  • This avoids import-time side effects and incorrect assumptions about system architecture.

4. Documentation fixes

  • Cleaned up broken markdown code blocks in INSTALL.md.
  • Removed internal implementation notes that were not appropriate for user-facing docs.
  • Added proper guidance for cloud GPU users to export:
    LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
    before launching the application.

5. Minor cleanup

  • Removed unused import sys.

Verification

Tested on:

  • Lightning AI Cloud
  • GPU: L4
  • OS: Ubuntu 22.04

Results:

  • Audio generation completes successfully without torchcodec-related crashes.
  • FLAC export works reliably using the soundfile backend.
  • Default format behavior remains unchanged unless explicitly overridden via environment variable.
  • No regressions observed in MP3/WAV/Opus/AAC paths.

This keeps the fix aligned with the intended design:

  • No silent behavior changes
  • No import-time environment mutation
  • Provides a safe, user-controlled workaround for cloud environments

Happy to make further adjustments if needed.

@ChuxiJ
Copy link
Copy Markdown
Contributor

ChuxiJ commented Apr 15, 2026

Thanks @sobiswriter — the revised diff addresses the original blockers cleanly. The opt-in ACESTEP_FORCE_FLAC_EXPORT env-var pattern is exactly the right shape, and removing the module-level LD_LIBRARY_PATH side effect is the correct call.

Two small things still need a touch-up before this can land:

1. .env.example ships the override enabled by default

-
+ACESTEP_FORCE_FLAC_EXPORT=1

Because .env.example is the template users copy to .env, shipping this as =1 means every new user silently gets FLAC-forced output regardless of what they pick in the Gradio UI. That reintroduces the "caller's format choice is silently ignored" regression that the revision was meant to avoid — just through a different door.

Please either:

  • Set it to =0 (explicit off), or
  • Comment the line out and add a brief note above it, e.g.
    # Force all audio exports to FLAC as a workaround for torchcodec/FFmpeg
    # load failures on some cloud GPU environments (Lightning AI, Lambda, etc.).
    # Leave unset or =0 to respect the format chosen in the UI.
    #ACESTEP_FORCE_FLAC_EXPORT=0
    

The second form is probably better — it documents intent and doesn't change behavior for anyone who copies the example.

2. docs/en/INSTALL.md fenced block is still structurally broken

Two issues with the current rendering:

  • The > ```bash block opened inside the [!IMPORTANT] blockquote is never closed — there's no matching > ``` line. Markdown renderers will swallow the rest of the section (including the > **Note:** Git must be installed... line below) into the code block.
  • Inside that same > ```bash block, the line > If you encounter torchcodec / FFmpeg related errors during audio export: is prose being rendered as shell code. The export LD_LIBRARY_PATH=... line belongs in a code block; the explanatory sentence does not.

Suggested fix — split prose and code, each fenced block opens and closes cleanly:

> [!IMPORTANT]
> **Cloud GPU Users (Lightning AI, Lambda, etc.):**
> To prevent audio export crashes (`libtorchcodec` or `libavutil` errors), install the required system packages **before** running the app:
>
> ```bash
> sudo apt-get update && sudo apt-get install -y ffmpeg libavdevice60 libavcodec-extra
> ```
>
> If you still see torchcodec / FFmpeg load errors, export `LD_LIBRARY_PATH` in the same shell that launches the app:
>
> ```bash
> export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
> ```

Each fenced block opens and closes cleanly on its own > ``` line, prose lives outside code blocks, and the > **Note:** Git must be installed... section below it will render correctly.

Optional nit (non-blocking)

acestep/audio_utils.py:316-320 still carries the channels_first=Truechannels_first=channels_first change and the #backend="soundfile" #safe dependency comment in the else: branch. That branch is unreachable on main (format is normalized to one of six valid values earlier), so this is harmless — but since it's dead code, the cleanest thing is to leave that block untouched relative to main and drop both edits. Not a blocker.

Once the two items above are addressed, I think this is good to merge. Nice work on the turnaround.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
acestep/audio_utils.py (1)

219-221: ⚠️ Potential issue | 🔴 Critical

Force-FLAC can still write FLAC data under non-FLAC extensions.

When ACESTEP_FORCE_FLAC_EXPORT=1 (Line 219–221), format becomes FLAC, but existing known suffixes (Line 232) are preserved. A .mp3 path can therefore contain FLAC bytes.

💡 Proposed fix
         force_flac = os.getenv("ACESTEP_FORCE_FLAC_EXPORT", "0") == "1"
         if force_flac:
-            format = "flac" 
+            format = "flac"

         # Ensure output path has correct extension
         output_path = Path(output_path)

         # Determine extension based on format
         ext = ".wav" if format == "wav32" else f".{format}"
+        if force_flac and output_path.suffix.lower() != ext:
+            output_path = output_path.with_suffix(ext)

         if output_path.suffix.lower() not in [".flac", ".wav", ".mp3", ".opus", ".aac", ".m4a"]:
             output_path = output_path.with_suffix(ext)

Also applies to: 227-239

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@acestep/audio_utils.py` around lines 219 - 221, The force-FLAC option sets
the encoding variable format = "flac" (ACESTEP_FORCE_FLAC_EXPORT) but does not
change the output filename/suffix, which can lead to FLAC bytes being written to
e.g. .mp3 files; update the export path logic (where known suffixes are handled
and where format is used, e.g., the variable format and any code that builds
output_path or preserves existing suffixes) so that when format == "flac" you
also set the file extension to ".flac" (use Path.with_suffix or os.path.splitext
to replace the suffix), and apply the same fix in the other block referenced
(lines around 227–239) to ensure filename suffix always matches the chosen
format.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@acestep/audio_utils.py`:
- Around line 219-221: The force-FLAC option sets the encoding variable format =
"flac" (ACESTEP_FORCE_FLAC_EXPORT) but does not change the output
filename/suffix, which can lead to FLAC bytes being written to e.g. .mp3 files;
update the export path logic (where known suffixes are handled and where format
is used, e.g., the variable format and any code that builds output_path or
preserves existing suffixes) so that when format == "flac" you also set the file
extension to ".flac" (use Path.with_suffix or os.path.splitext to replace the
suffix), and apply the same fix in the other block referenced (lines around
227–239) to ensure filename suffix always matches the chosen format.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ca7d8863-2cad-49af-8acc-89a3af70a4b4

📥 Commits

Reviewing files that changed from the base of the PR and between 0457406 and 025006e.

📒 Files selected for processing (1)
  • acestep/audio_utils.py

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
docs/en/INSTALL.md (1)

143-143: Optional: Remove blank line inside blockquote.

Line 143 contains a blank line within the Markdown blockquote (> with no content), triggering markdownlint rule MD028. While this doesn't affect rendering, removing it would clean up the structure.

♻️ Proposed cleanup
 > ```bash
 > export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
 > ```
->
-
+
 > **Note:** Git must be installed via your system package manager (`sudo apt install git`, `sudo yum install git`, `sudo pacman -S git`).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/en/INSTALL.md` at line 143, Remove the empty blockquote line that
triggers MD028: locate the blockquote sequence that starts with lines containing
leading '>' markers around the code block and the subsequent Note (the lines
with "> ```", the lone "> " blank line, and "> **Note:** ..."), and delete the
solitary "> " blank line so the code fence and the following note remain
consecutive within the blockquote.
.env.example (1)

57-58: Optional: Remove extra blank lines.

Two consecutive blank lines create unnecessary spacing. Consider reducing to a single blank line for cleaner formatting.

♻️ Proposed cleanup
 # ACESTEP_FORCE_FLAC_EXPORT=0
-

-

+
 # ==================== Model Storage ====================
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.env.example around lines 57 - 58, Remove the unnecessary consecutive blank
lines in .env.example (the extra empty line sequence near the middle of the
file) so that only a single blank line remains between sections; simply delete
the extra blank line to clean up formatting and keep consistent spacing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In @.env.example:
- Around line 57-58: Remove the unnecessary consecutive blank lines in
.env.example (the extra empty line sequence near the middle of the file) so that
only a single blank line remains between sections; simply delete the extra blank
line to clean up formatting and keep consistent spacing.

In `@docs/en/INSTALL.md`:
- Line 143: Remove the empty blockquote line that triggers MD028: locate the
blockquote sequence that starts with lines containing leading '>' markers around
the code block and the subsequent Note (the lines with "> ```", the lone "> "
blank line, and "> **Note:** ..."), and delete the solitary "> " blank line so
the code fence and the following note remain consecutive within the blockquote.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7c5ecc80-57ff-4945-bf35-e791583b0b70

📥 Commits

Reviewing files that changed from the base of the PR and between 025006e and 16be021.

📒 Files selected for processing (2)
  • .env.example
  • docs/en/INSTALL.md

@sobiswriter
Copy link
Copy Markdown
Author

sobiswriter commented Apr 15, 2026

Thanks for the detailed follow-up @ChuxiJ — I’ve addressed the remaining points.

Final updates

1. .env.example behavior

  • Removed the default ACESTEP_FORCE_FLAC_EXPORT=1.
  • Replaced with a commented, documented option so users must explicitly opt-in.
  • This ensures format selection from the UI is respected by default.

2. INSTALL.md fixes

  • Corrected all markdown fencing issues in the Linux section.
  • Ensured code blocks open/close cleanly and are not nested incorrectly.
  • Separated prose from shell commands to avoid rendering issues.
  • The LD_LIBRARY_PATH export is now properly documented as a user-side step.

3. General cleanup

  • Left the unreachable branch unchanged (per suggestion, non-blocking).
  • No functional changes beyond the intended opt-in FLAC workaround.

Verification

Tested again on:

  • Lightning AI Cloud
  • GPU: L4
  • OS: Ubuntu 22.04

Results:

  • Audio export completes without torchcodec-related crashes.
  • Default format selection works correctly across all supported formats.
  • FLAC override works only when explicitly enabled via environment variable.
  • No regressions observed.

This keeps the fix aligned with project expectations:

  • No silent behavior changes
  • No import-time environment mutations
  • Clear, user-controlled workaround for cloud environments

Thanks again for the guidance — happy to make any final tweaks if needed. Thanks a lot another review again as I said, I'm kinda new to all this and opensourcing n all but I still try to do my best. It will surely be a big deal for me if I could become a contirbuter here. Tnks u ppl.. ;)

Removed extra blank lines and clarified Git installation note.
Removed unnecessary blank lines in the .env.example file.
@sobiswriter
Copy link
Copy Markdown
Author

Hello out there @ChuxiJ it's been long, I was hopping if u'd look at the changes and suggest anything.. If not, then accept the commit, It would really put me to ease as well. Thank u......

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.

2 participants