Spaces:
Starting
on
T4
Starting
on
T4
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 | |
async def hello_world(): | |
return {"message": "Hello, World!"} | |
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 | |
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 | |