Skip to content
10 changes: 8 additions & 2 deletions acestep/audio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import io
import json
import os
# Force the system to look in the correct folder for FFmpeg libraries
os.environ["LD_LIBRARY_PATH"] = "/usr/lib/x86_64-linux-gnu:" + os.environ.get("LD_LIBRARY_PATH", "")

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
import subprocess
import hashlib
import tempfile
Expand All @@ -20,6 +23,7 @@
import numpy as np
import torchaudio
from loguru import logger
import sys
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated


def apply_fade(
Expand Down Expand Up @@ -215,7 +219,7 @@ def save_audio(
Returns:
Actual saved file path
"""
format = (format or self.default_format).lower()
format = "flac"
if format not in ["flac", "wav", "mp3", "wav32", "opus", "aac"]:
logger.warning(f"Unsupported format {format}, using {self.default_format}")
format = self.default_format
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
Expand Down Expand Up @@ -309,8 +313,10 @@ def save_audio(
str(output_path),
audio_tensor,
sample_rate,
channels_first=True,
channels_first=channels_first,
backend="soundfile" # <--- ADD THIS LINE
)


logger.debug(f"[AudioSaver] Saved audio to {output_path} ({format}, {sample_rate}Hz)")
return str(output_path)
Expand Down
17 changes: 16 additions & 1 deletion docs/en/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,22 @@ chmod +x start_gradio_ui.sh start_api_server.sh

# Launch REST API Server
./start_api_server.sh
```

> [!IMPORTANT]
> **Cloud GPU Users (Lightning AI, Lambda, etc.):**
> To prevent audio export crashes (`libtorchcodec` or `libavutil` errors), you must install the following system dependencies before running the application:
> ```bash
> sudo apt-get update && sudo apt-get install -y ffmpeg libavdevice60 libavcodec-extra
> ```

In acestep/audio_utils.py:
Added os.environ["LD_LIBRARY_PATH"] initialization at the module level.
Modified save_audio() to prioritize flac or wav formats, ensuring the backend="soundfile" parameter is utilized during the torchaudio.save call for maximum compatibility.


```bash


Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

> **Note:** Git must be installed via your system package manager (`sudo apt install git`, `sudo yum install git`, `sudo pacman -S git`).

Expand Down