fix(training): resolve Gin route conflicts and fix TTS Dockerfile
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 36s
CI / test-python-backend-compliance (push) Successful in 30s
CI / test-python-document-crawler (push) Successful in 24s
CI / test-python-dsms-gateway (push) Successful in 17s
All checks were successful
CI / go-lint (push) Has been skipped
CI / python-lint (push) Has been skipped
CI / nodejs-lint (push) Has been skipped
CI / test-go-ai-compliance (push) Successful in 36s
CI / test-python-backend-compliance (push) Successful in 30s
CI / test-python-document-crawler (push) Successful in 24s
CI / test-python-dsms-gateway (push) Successful in 17s
- Fix route param conflict: /content/publish/:id instead of /content/:id/publish - Fix route conflict: /media/module/:moduleId for module media list - Use Piper binary instead of pip package (ARM64 compatibility) - Update frontend API URLs to match new routes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -288,15 +288,15 @@ export async function generateAudio(moduleId: string): Promise<TrainingMedia> {
|
||||
}
|
||||
|
||||
export async function getModuleMedia(moduleId: string): Promise<{ media: TrainingMedia[]; total: number }> {
|
||||
return apiFetch(`/media/${moduleId}`)
|
||||
return apiFetch(`/media/module/${moduleId}`)
|
||||
}
|
||||
|
||||
export async function getMediaURL(mediaId: string): Promise<{ bucket: string; object_key: string; mime_type: string }> {
|
||||
return apiFetch(`/media/${mediaId}/url`)
|
||||
return apiFetch(`/media/module/${mediaId}/url`)
|
||||
}
|
||||
|
||||
export async function publishMedia(mediaId: string, publish?: boolean): Promise<{ status: string; is_published: boolean }> {
|
||||
return apiFetch(`/media/${mediaId}/publish`, {
|
||||
return apiFetch(`/media/module/${mediaId}/publish`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ publish: publish !== false }),
|
||||
})
|
||||
|
||||
@@ -721,11 +721,11 @@ func main() {
|
||||
trainingRoutes.POST("/content/generate-all", trainingHandlers.GenerateAllContent)
|
||||
trainingRoutes.POST("/content/generate-all-quiz", trainingHandlers.GenerateAllQuizzes)
|
||||
trainingRoutes.GET("/content/:moduleId", trainingHandlers.GetContent)
|
||||
trainingRoutes.POST("/content/:id/publish", trainingHandlers.PublishContent)
|
||||
trainingRoutes.POST("/content/publish/:id", trainingHandlers.PublishContent)
|
||||
|
||||
// Audio/Media
|
||||
trainingRoutes.POST("/content/:moduleId/generate-audio", trainingHandlers.GenerateAudio)
|
||||
trainingRoutes.GET("/media/:moduleId", trainingHandlers.GetModuleMedia)
|
||||
trainingRoutes.GET("/media/module/:moduleId", trainingHandlers.GetModuleMedia)
|
||||
trainingRoutes.GET("/media/:id/url", trainingHandlers.GetMediaURL)
|
||||
trainingRoutes.POST("/media/:id/publish", trainingHandlers.PublishMedia)
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
# System dependencies
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ffmpeg \
|
||||
libsndfile1 \
|
||||
imagemagick \
|
||||
fonts-dejavu-core \
|
||||
wget \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg libsndfile1 imagemagick fonts-dejavu-core wget curl && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Piper binary (pre-built for aarch64)
|
||||
RUN mkdir -p /opt/piper && ARCH=$(dpkg --print-architecture) && if [ "$ARCH" = "arm64" ]; then PIPER_ARCH="aarch64"; else PIPER_ARCH="x86_64"; fi && wget -q -O /tmp/piper.tar.gz "https://github.com/rhasspy/piper/releases/download/2023.11.14-2/piper_linux_${PIPER_ARCH}.tar.gz" && tar -xzf /tmp/piper.tar.gz -C /opt/ && rm /tmp/piper.tar.gz && ln -s /opt/piper/piper /usr/local/bin/piper
|
||||
|
||||
# Create non-root user
|
||||
RUN useradd -m -u 1000 ttsuser
|
||||
@@ -18,27 +15,20 @@ WORKDIR /app
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Download Piper model (German, thorsten, high quality)
|
||||
RUN mkdir -p /app/models && \
|
||||
wget -q -O /app/models/de_DE-thorsten-high.onnx \
|
||||
"https://huggingface.co/rhasspy/piper-voices/resolve/main/de/de_DE/thorsten/high/de_DE-thorsten-high.onnx" && \
|
||||
wget -q -O /app/models/de_DE-thorsten-high.onnx.json \
|
||||
"https://huggingface.co/rhasspy/piper-voices/resolve/main/de/de_DE/thorsten/high/de_DE-thorsten-high.onnx.json"
|
||||
# Download Piper voice model (German, thorsten, high quality)
|
||||
RUN mkdir -p /app/models && wget -q -O /app/models/de_DE-thorsten-high.onnx "https://huggingface.co/rhasspy/piper-voices/resolve/main/de/de_DE/thorsten/high/de_DE-thorsten-high.onnx" && wget -q -O /app/models/de_DE-thorsten-high.onnx.json "https://huggingface.co/rhasspy/piper-voices/resolve/main/de/de_DE/thorsten/high/de_DE-thorsten-high.onnx.json"
|
||||
|
||||
# Copy application
|
||||
COPY . .
|
||||
|
||||
# Fix ImageMagick policy for PDF/text rendering
|
||||
RUN if [ -f /etc/ImageMagick-6/policy.xml ]; then \
|
||||
sed -i 's/rights="none" pattern="PDF"/rights="read|write" pattern="PDF"/' /etc/ImageMagick-6/policy.xml; \
|
||||
fi
|
||||
# Fix ImageMagick policy for text rendering
|
||||
RUN if [ -f /etc/ImageMagick-6/policy.xml ]; then sed -i "s/rights=\"none\" pattern=\"PDF\"/rights=\"read|write\" pattern=\"PDF\"/" /etc/ImageMagick-6/policy.xml; fi
|
||||
|
||||
RUN chown -R ttsuser:ttsuser /app
|
||||
USER ttsuser
|
||||
|
||||
EXPOSE 8095
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
||||
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8095/health')"
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 CMD curl -sf http://127.0.0.1:8095/health || exit 1
|
||||
|
||||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8095"]
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
fastapi==0.109.2
|
||||
uvicorn[standard]==0.27.1
|
||||
piper-tts==1.2.0
|
||||
boto3==1.34.25
|
||||
python-multipart==0.0.6
|
||||
pydantic==2.6.1
|
||||
|
||||
Reference in New Issue
Block a user