Spaces:
Runtime error
Runtime error
File size: 2,079 Bytes
04aba43 f43af24 0dfbf11 a361896 f43af24 04aba43 f43af24 0dfbf11 f43af24 04aba43 a361896 f43af24 a361896 0dfbf11 f43af24 0dfbf11 f43af24 04aba43 f43af24 0dfbf11 f43af24 04aba43 f43af24 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
FROM python:3.11-slim
# System environment
ENV VENV_PATH="/home/appuser/venv"
ENV PATH="$VENV_PATH/bin:$PATH"
ENV HF_HOME="/home/appuser/.cache/huggingface"
# Create user
RUN useradd -ms /bin/bash appuser
USER root
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ffmpeg \
espeak-ng \
wget \
git \
curl \
python3-venv && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Switch to non-root user
USER appuser
WORKDIR /home/appuser
# Setup virtual environment
RUN python3 -m venv $VENV_PATH && \
$VENV_PATH/bin/pip install --upgrade pip && \
$VENV_PATH/bin/pip install audiblez huggingface_hub
# Download Kokoro model and voices
RUN mkdir -p /home/appuser/.local/share/audiblez && \
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/kokoro-v0_19.onnx -P /home/appuser/.local/share/audiblez && \
wget https://github.com/thewh1teagle/kokoro-onnx/releases/download/model-files/voices.json -P /home/appuser/.local/share/audiblez
# Create ebook and output folders
RUN mkdir -p /home/appuser/ebooks /home/appuser/m4b
# Copy EPUBs from Hugging Face Space (example with 2 test books, update as needed)
RUN wget https://huggingface.co/spaces/MoiMoi-01/AudiobookMakerAudiblezTrial/resolve/main/ebooks/MyDescendantBeggedMeToHelpHimJustAfterIBecameAGod.epub -P /home/appuser/ebooks && \
wget https://huggingface.co/spaces/MoiMoi-01/AudiobookMakerAudiblezTrial/resolve/main/ebooks/MySwordIntentCanBeInfinitelyImproved.epub -P /home/appuser/ebooks
# Final command to convert and upload m4b files
CMD for book in /home/appuser/ebooks/*.epub; do \
$VENV_PATH/bin/audiblez "$book" -v af_sky; \
done && \
cp *.m4b /home/appuser/m4b && \
echo "Uploading to Hugging Face..." && \
$VENV_PATH/bin/huggingface-cli login --token $HF_TOKEN && \
cd /home/appuser/m4b && \
for file in *.m4b; do \
huggingface-cli upload MoiMoi-01/AudiobookMakerAudiblezTrial "$file" --path_in_repo m4b/"$file"; \
done
|