Spaces:
Sleeping
Sleeping
File size: 1,137 Bytes
6b96454 1727a7e 6b96454 1727a7e 6b96454 1727a7e 6b96454 1727a7e 6b96454 1727a7e cd7af42 1727a7e 6b96454 1727a7e 6b96454 1727a7e 6b96454 1727a7e cd7af42 1727a7e 6b96454 |
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 |
from fastapi import FastAPI, HTTPException
from pydantic import BaseModel
from audio_analyzer import AudioAnalyzer
from video_analyzer import VideoAnalyzer
app = FastAPI()
class AudioRequest(BaseModel):
audio_url: str
class VideoRequest(BaseModel):
video_url: str
@app.get("/")
async def hello_world():
return {"message": "Hello, World!"}
@app.post("/v1/analyze_audio")
async def analyze_audio(request: AudioRequest):
audio_url = request.audio_url
if not audio_url:
raise HTTPException(status_code=400, detail="audio_url is required")
print(f"Analyzing audio... {audio_url}")
analyzer = AudioAnalyzer(media_url=audio_url, media_type="audio")
traits = analyzer.retrieve_traits()
return traits
@app.post("/v1/analyze_video")
async def analyze_video(request: VideoRequest):
video_url = request.video_url
if not video_url:
raise HTTPException(status_code=400, detail="video_url is required")
print(f"Analyzing video... {video_url}")
analyzer = VideoAnalyzer(video_url=video_url)
traits = analyzer.retrieve_traits()
return traits
|