Skip to content

Commit

Permalink
urlparse
Browse files Browse the repository at this point in the history
  • Loading branch information
SanderGi authored and devxpy committed Jul 30, 2024
1 parent bac13dd commit e8ece05
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions retro/sadtalker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from functools import lru_cache
from tempfile import TemporaryDirectory
import requests
import random
from urllib.parse import urlparse

import cv2
import numpy as np
Expand Down Expand Up @@ -151,11 +151,13 @@ def sadtalker(
) -> InputOutputVideoMetadata:
assert len(pipeline.upload_urls) == 1, "Expected exactly 1 upload url"

face_mime_type = mimetypes.guess_type(inputs.source_image.split("?")[0])[0] or ""
face_url_without_query = urlparse(inputs.source_image)._replace(query={}).geturl()
face_mime_type = mimetypes.guess_type(face_url_without_query)[0] or ""
if not ("video/" in face_mime_type or "image/" in face_mime_type):
raise ValueError(f"Unsupported face format {face_mime_type!r}")

audio_mime_type = mimetypes.guess_type(inputs.driven_audio.split("?")[0])[0] or ""
audio_url_without_query = urlparse(inputs.driven_audio)._replace(query={}).geturl()
audio_mime_type = mimetypes.guess_type(audio_url_without_query)[0] or ""
if not ("audio/" in audio_mime_type or "video/" in audio_mime_type):
raise ValueError(f"Unsupported audio format {audio_mime_type!r}")

Expand Down

0 comments on commit e8ece05

Please sign in to comment.