muhammadnoman76 commited on
Commit
dde038e
·
1 Parent(s): 0d14332
Files changed (3) hide show
  1. Dockerfile +39 -0
  2. README.md +40 -6
  3. entrypoint.sh +59 -0
Dockerfile ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Set environment variables
4
+ ENV PYTHONDONTWRITEBYTECODE=1 \
5
+ PYTHONUNBUFFERED=1 \
6
+ PIP_NO_CACHE_DIR=1 \
7
+ PIP_DISABLE_PIP_VERSION_CHECK=1 \
8
+ PORT=7860
9
+
10
+ # Install system dependencies
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ ffmpeg \
13
+ git \
14
+ && rm -rf /var/lib/apt/lists/*
15
+
16
+ # Create non-root user (Hugging Face Spaces requirement)
17
+ RUN useradd -m -u 1000 user
18
+ ENV HOME=/home/user \
19
+ PATH=/home/user/.local/bin:$PATH
20
+
21
+ # Set work directory
22
+ WORKDIR $HOME/app
23
+
24
+ # Copy entrypoint script
25
+ COPY --chown=user entrypoint.sh $HOME/app/entrypoint.sh
26
+ RUN chmod +x $HOME/app/entrypoint.sh
27
+
28
+ # Switch to non-root user
29
+ USER user
30
+
31
+ # Expose port (Hugging Face uses 7860)
32
+ EXPOSE 7860
33
+
34
+ # Health check
35
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
36
+ CMD python -c "import httpx; httpx.get('http://localhost:7860/health')" || exit 1
37
+
38
+ # Run entrypoint
39
+ CMD ["/home/user/app/entrypoint.sh"]
README.md CHANGED
@@ -1,11 +1,45 @@
1
  ---
2
- title: Langvoice
3
- emoji: 🌖
4
- colorFrom: blue
5
- colorTo: red
6
  sdk: docker
 
7
  pinned: false
8
- license: cc-by-nc-nd-3.0
9
  ---
10
 
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: LangVoice API
3
+ emoji: 🎙️
4
+ colorFrom: purple
5
+ colorTo: blue
6
  sdk: docker
7
+ app_port: 7860
8
  pinned: false
 
9
  ---
10
 
11
+ # LangVoice API - Hugging Face Deployment
12
+
13
+ This Space runs the LangVoice Text-to-Speech API backend.
14
+
15
+ ## Setup
16
+
17
+ ### Required Secrets
18
+
19
+ Set the following secrets in your Hugging Face Space settings:
20
+
21
+ 1. **GITHUB_TOKEN** - Personal access token with `repo` scope to clone the private langvoice repository
22
+ 2. **MONGODB_URL** - MongoDB connection string (e.g., `mongodb+srv://user:pass@cluster.mongodb.net/langvoice`)
23
+ 3. **SECRET_KEY** - JWT secret key for authentication
24
+
25
+ ### Optional Environment Variables
26
+
27
+ - `ADMIN_EMAIL` - Admin user email (default: admin@langvoice.com)
28
+ - `ADMIN_PASSWORD` - Admin user password
29
+ - `DEBUG` - Set to `true` for debug mode
30
+
31
+ ## API Endpoints
32
+
33
+ Once deployed, the API will be available at:
34
+
35
+ - **API Docs**: `https://your-space.hf.space/docs`
36
+ - **Health Check**: `https://your-space.hf.space/health`
37
+ - **OpenAPI JSON**: `https://your-space.hf.space/openapi.json`
38
+
39
+ ## Features
40
+
41
+ - 28+ natural voices across American and British English
42
+ - 9 languages including English, Spanish, French, Hindi, Japanese
43
+ - Multi-voice conversations for dialogues
44
+ - Rate limiting with custom per-user limits
45
+ - JWT and API key authentication
entrypoint.sh ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ echo "=========================================="
5
+ echo "LangVoice Backend - Hugging Face Deployment"
6
+ echo "=========================================="
7
+
8
+ APP_DIR="$HOME/app"
9
+ BACKEND_DIR="$APP_DIR/langvoice_backend"
10
+
11
+ # Check if the backend is already set up
12
+ if [ ! -d "$BACKEND_DIR/app" ]; then
13
+ echo "First run detected. Setting up application..."
14
+
15
+ # Check for GitHub token
16
+ if [ -z "$GITHUB_TOKEN" ]; then
17
+ echo "Error: GITHUB_TOKEN is not set"
18
+ echo "Please set GITHUB_TOKEN as a Hugging Face Space secret"
19
+ exit 1
20
+ fi
21
+
22
+ # Clone the langvoice repository
23
+ echo "Cloning langvoice repository..."
24
+ git clone --depth 1 https://${GITHUB_TOKEN}@github.com/nomanalisyed2/{YOUR_REPO_NAME}.git /tmp/langvoice
25
+
26
+ # Copy backend files
27
+ echo "Copying backend files..."
28
+ mkdir -p "$BACKEND_DIR"
29
+ cp -r /tmp/langvoice/langvoice_backend/* "$BACKEND_DIR/"
30
+
31
+ # Clean up
32
+ rm -rf /tmp/langvoice
33
+
34
+ # Install Python dependencies
35
+ echo "Installing Python dependencies..."
36
+ cd "$BACKEND_DIR"
37
+ pip install --user -e .
38
+
39
+ echo "Setup complete!"
40
+ else
41
+ echo "Backend already set up. Skipping clone..."
42
+ fi
43
+
44
+ # Navigate to backend directory
45
+ cd "$BACKEND_DIR"
46
+
47
+ # Create any required directories
48
+ mkdir -p uploads
49
+
50
+ # Set environment variables for Hugging Face
51
+ export HOST="0.0.0.0"
52
+ export PORT="${PORT:-7860}"
53
+
54
+ echo "=========================================="
55
+ echo "Starting LangVoice Backend on port $PORT"
56
+ echo "=========================================="
57
+
58
+ # Run the FastAPI application
59
+ exec python -m uvicorn app.main:app --host 0.0.0.0 --port $PORT