ai-sl-api / README.md
deenasun's picture
add cloudflare upload and base64 for video output response to gradio
dadcb61
|
raw
history blame
2.58 kB
metadata
title: AI-powered ASL text-to-video Generator
emoji: 🐻
colorFrom: blue
colorTo: yellow
sdk: gradio
sdk_version: 5.34.2
app_file: app.py
pinned: false
license: apache-2.0

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

AI-SL API

Convert text documents to American Sign Language (ASL) videos using AI.

Video Output Options

The Gradio interface provides multiple ways for users to receive and download the generated ASL videos:

1. R2 Cloud Storage (Recommended)

  • Videos are automatically uploaded to Cloudflare R2 storage
  • Returns a public URL that users can download directly
  • Videos persist and can be shared via URL
  • Includes a styled download button in the interface

2. Base64 Encoding (Alternative)

  • Videos are embedded as base64 data directly in the response
  • No external storage required
  • Good for smaller videos or when you want to avoid cloud storage
  • Can be downloaded directly from the interface

3. Programmatic Access

Users can access the video output programmatically using:

from gradio_client import Client

# Connect to the running interface
client = Client("http://localhost:7860")

# Upload a document and get results
result = client.predict(
    "path/to/document.pdf",
    api_name="/predict"
)

# The result contains: (json_data, video_output, download_html)
json_data, video_url, download_html = result

# Download the video
import requests
response = requests.get(video_url)
with open("asl_video.mp4", "wb") as f:
    f.write(response.content)

4. Direct Download from Interface

  • The interface includes a styled download button
  • Users can right-click and "Save As" if automatic download doesn't work
  • Video files are named asl_video.mp4 by default

Example Usage

See example_usage.py for complete examples of how to:

  • Download videos from URLs
  • Process base64 video data
  • Use the interface programmatically
  • Perform further video processing

Requirements

  • Python 3.7+
  • Required packages listed in requirements.txt
  • Cloudflare R2 credentials (for cloud storage option)
  • Supabase credentials for video database

Setup

  1. Install dependencies: pip install -r requirements.txt
  2. Set up environment variables in .env file
  3. Run the interface: python app.py

Video Processing

Once you have the video file, you can:

  • Upload to YouTube, Google Drive, or other services
  • Analyze with OpenCV for computer vision tasks
  • Convert to different formats
  • Extract frames for further processing
  • Add subtitles or overlays