Spaces:
Sleeping
Sleeping
|
Download README.md from Rthur2003/crowncode-backend: direct link, hf CLI and curl.
- Browser
- Download file 4.82 kB
-
https://huggingface.co/spaces/Rthur2003/crowncode-backend/resolve/08942e6c3f33c3da41e3a03bfa5294c0bb3a6d21/README.md
- Command line
-
hf download hf://spaces/Rthur2003/crowncode-backend@08942e6c3f33c3da41e3a03bfa5294c0bb3a6d21/README.md
-
curl -L -o README.md https://huggingface.co/spaces/Rthur2003/crowncode-backend/resolve/08942e6c3f33c3da41e3a03bfa5294c0bb3a6d21/README.md
4.82 kB
| title: CrownCode Backend | |
| emoji: 👑 | |
| colorFrom: yellow | |
| colorTo: red | |
| sdk: docker | |
| pinned: false | |
| # CrownCode Backend | |
| YouTube-first backend service for AI music detection workflows. | |
| --- | |
| ## Hugging Face Spaces Deployment | |
| ### Quick Deploy | |
| 1. **Hugging Face Space Olustur** | |
| - [huggingface.co/new-space](https://huggingface.co/new-space) adresine git | |
| - Space Name: `crowncode-backend` | |
| - SDK: **Docker** (onemli!) | |
| - Hardware: **CPU Basic (Free)** | |
| 2. **Dosyalari Yukle** | |
| - Space sayfasinda "Files" sekmesine git | |
| - "Add file" > "Upload files" tikla | |
| - Su dosyalari yukle: | |
| - `Dockerfile` | |
| - `requirements.txt` | |
| - `app/` klasoru (tum icerigi ile) | |
| 3. **Deploy** | |
| - "Commit changes" butonuna bas | |
| - 3-5 dakika icinde build tamamlanir | |
| ### URL Format | |
| ``` | |
| https://KULLANICI_ADI-crowncode-backend.hf.space | |
| ``` | |
| ### Test Endpoints | |
| ``` | |
| GET /api/health -> {"status": "healthy"} | |
| GET /docs -> Swagger UI | |
| POST /api/youtube/analyze | |
| ``` | |
| --- | |
| ## What This Service Does | |
| - Accepts a YouTube URL | |
| - Downloads audio via `yt-dlp` | |
| - Optionally forwards the audio to external services: | |
| - Music-AIDetector (`/predict`) | |
| - Ses-Analizi (`/analyze`) | |
| - Produces a deterministic preview decision if no model is available | |
| --- | |
| ## Structure | |
| ``` | |
| hf-crowncode-backend/ | |
| Dockerfile <- Hugging Face Spaces icin | |
| requirements.txt <- CPU-compatible dependencies | |
| app/ | |
| main.py | |
| schemas.py | |
| routes/ | |
| health.py | |
| analyze.py | |
| data_processing.py | |
| commend/ | |
| router.py | |
| youtube_service.py | |
| services/ | |
| external_clients.py | |
| url_parser.py | |
| youtube_analysis.py | |
| youtube_downloader.py | |
| audio_processor.py | |
| validation.py | |
| logging_config.py | |
| preview_model.py | |
| ``` | |
| --- | |
| ## API Endpoints | |
| | Method | Endpoint | Description | | |
| |--------|----------|-------------| | |
| | GET | `/api/health` | Health check | | |
| | POST | `/api/analyze` | Analyze YouTube URL or uploaded file | | |
| | POST | `/api/process/audio` | Audio augmentation | | |
| | GET | `/api/commend/health` | Crown Commend health check | | |
| | POST | `/api/commend/generate` | Generate AI comment for YouTube | | |
| | POST | `/api/commend/post` | Post comment to YouTube (feature-flagged) | | |
| | GET | `/api/commend/styles` | Get available comment styles | | |
| ### POST /api/analyze | |
| Request (multipart form): | |
| - `sourceType`: `youtube` | `file` | `spotify` | `apple` | |
| - `url`: YouTube URL (when sourceType=youtube) | |
| - `file`: Audio file upload (when sourceType=file) | |
| Response: | |
| ```json | |
| { | |
| "result": { | |
| "isAIGenerated": true, | |
| "confidence": 0.85, | |
| "processingTime": 2.1, | |
| "modelVersion": "preview-v2-enhanced", | |
| "decisionSource": "preview", | |
| "analysisMode": "preview", | |
| "source": { "kind": "youtube", "videoId": "..." }, | |
| "features": { ... }, | |
| "audioInfo": { ... } | |
| }, | |
| "warnings": [], | |
| "errors": [] | |
| } | |
| ``` | |
| --- | |
| ## Environment Variables | |
| | Variable | Default | Description | | |
| |----------|---------|-------------| | |
| | `CROWNCODE_CORS_ORIGINS` | `http://localhost:3000` | Allowed CORS origins (comma-separated). **Do not use `*` in production.** | | |
| | `MUSIC_AI_API_URL` | - | Music-AIDetector service URL | | |
| | `SES_ANALIZI_API_URL` | - | Ses-Analizi service URL | | |
| | `CROWNCODE_API_TIMEOUT_SEC` | `30` | External service timeout | | |
| | `SES_ANALIZI_THRESHOLD` | `0.5` | Authenticity score threshold | | |
| | `LOG_LEVEL` | `INFO` | Logging level | | |
| | `COMMEND_GEMINI_API_KEY` | - | Gemini API key for Crown Commend (also used as YouTube API Key fallback) | | |
| | `COMMEND_YOUTUBE_API_KEY` | - | YouTube Data API key for read operations (optional if Gemini key is set) | | |
| | `COMMEND_TOKEN_JSON` | - | YouTube OAuth token JSON for posting comments (optional) | | |
| | `COMMEND_API_KEY` | - | API key for commend endpoint auth (**required in production**) | | |
| | `COMMEND_REQUIRE_AUTH` | `true` | Fail-closed auth gate. Set to `false` only for local development. | | |
| | `COMMEND_ENABLE_POSTING` | `false` | Enable YouTube comment posting (`true`/`false`) | | |
| --- | |
| ## Frontend Configuration | |
| Backend deploy edildikten sonra frontend `.env` dosyasini guncelle: | |
| ```env | |
| NEXT_PUBLIC_API_URL=https://kullaniciadi-crowncode-backend.hf.space | |
| ``` | |
| --- | |
| ## Local Development | |
| ```bash | |
| # Install dependencies | |
| pip install -r requirements.txt | |
| # Install PyTorch CPU | |
| pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu | |
| # Run server | |
| uvicorn app.main:app --reload --port 8000 | |
| ``` | |
| --- | |
| ## Docker Local Build | |
| ```bash | |
| docker build -t crowncode-backend . | |
| docker run -p 7860:7860 crowncode-backend | |
| ``` | |
| --- | |
| ## Notes | |
| - `yt-dlp` requires network access and works best with `ffmpeg` installed | |
| - When external services are not configured, returns preview decision | |
| - Hugging Face free tier has 16GB RAM and 2 vCPU | |
| - Build may take 5-10 minutes due to PyTorch installation | |