runapi-infinitetalk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runapi/infinitetalk/__init__.py +24 -0
- runapi/infinitetalk/client.py +30 -0
- runapi/infinitetalk/py.typed +0 -0
- runapi/infinitetalk/resources/__init__.py +3 -0
- runapi/infinitetalk/resources/audio_to_video.py +97 -0
- runapi/infinitetalk/types.py +30 -0
- runapi_infinitetalk-0.1.0.dist-info/METADATA +84 -0
- runapi_infinitetalk-0.1.0.dist-info/RECORD +9 -0
- runapi_infinitetalk-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""InfiniteTalk client for RunAPI."""
|
|
2
|
+
|
|
3
|
+
from runapi.core import (
|
|
4
|
+
AuthenticationError,
|
|
5
|
+
InsufficientCreditsError,
|
|
6
|
+
NotFoundError,
|
|
7
|
+
RateLimitError,
|
|
8
|
+
TaskFailedError,
|
|
9
|
+
TaskTimeoutError,
|
|
10
|
+
ValidationError,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
from .client import InfinitetalkClient
|
|
14
|
+
|
|
15
|
+
__all__ = [
|
|
16
|
+
"InfinitetalkClient",
|
|
17
|
+
"AuthenticationError",
|
|
18
|
+
"RateLimitError",
|
|
19
|
+
"InsufficientCreditsError",
|
|
20
|
+
"NotFoundError",
|
|
21
|
+
"ValidationError",
|
|
22
|
+
"TaskFailedError",
|
|
23
|
+
"TaskTimeoutError",
|
|
24
|
+
]
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""InfiniteTalk client."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
from runapi.core import ClientOptions, HttpClient, resolve_api_key
|
|
8
|
+
|
|
9
|
+
from .resources.audio_to_video import AudioToVideo
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class InfinitetalkClient:
|
|
13
|
+
"""InfiniteTalk audio-to-video client.
|
|
14
|
+
|
|
15
|
+
Example::
|
|
16
|
+
|
|
17
|
+
client = InfinitetalkClient(api_key="sk-...")
|
|
18
|
+
result = client.audio_to_video.run(
|
|
19
|
+
model="infinitetalk-from-audio",
|
|
20
|
+
source_image_url="https://example.com/face.jpg",
|
|
21
|
+
source_audio_url="https://example.com/voice.mp3",
|
|
22
|
+
prompt="A person speaking to the camera",
|
|
23
|
+
)
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, api_key: Optional[str] = None, **options: Any) -> None:
|
|
27
|
+
resolved_api_key = resolve_api_key(api_key)
|
|
28
|
+
client_options = ClientOptions(api_key=resolved_api_key, **options)
|
|
29
|
+
http = client_options.http_client or HttpClient(client_options)
|
|
30
|
+
self.audio_to_video = AudioToVideo(http)
|
|
File without changes
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""InfiniteTalk audio-to-video resource."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Dict
|
|
6
|
+
|
|
7
|
+
from runapi.core import Resource, ValidationError
|
|
8
|
+
|
|
9
|
+
from ..types import (
|
|
10
|
+
MODELS,
|
|
11
|
+
RESOLUTIONS,
|
|
12
|
+
AudioToVideoResponse,
|
|
13
|
+
CompletedAudioToVideoResponse,
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
PROMPT_MAX_LENGTH = 5000
|
|
17
|
+
SEED_RANGE = range(10_000, 1_000_001)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class AudioToVideo(Resource):
|
|
21
|
+
"""Generate a talking-head video from a source image and audio track."""
|
|
22
|
+
|
|
23
|
+
ENDPOINT = "/api/v1/infinitetalk/audio_to_video"
|
|
24
|
+
|
|
25
|
+
RESPONSE_CLASS = AudioToVideoResponse
|
|
26
|
+
COMPLETED_RESPONSE_CLASS = CompletedAudioToVideoResponse
|
|
27
|
+
|
|
28
|
+
def run(self, **params: Any) -> Any:
|
|
29
|
+
"""Create a task and poll until it completes."""
|
|
30
|
+
task = self.create(**params)
|
|
31
|
+
return self._poll_until_complete(lambda: self.get(task.id))
|
|
32
|
+
|
|
33
|
+
def create(self, **params: Any) -> Any:
|
|
34
|
+
"""Create an audio-to-video task and return immediately with an ``id``."""
|
|
35
|
+
compacted = self._compact_params(params)
|
|
36
|
+
self._validate_params(compacted)
|
|
37
|
+
return self._request("post", self.ENDPOINT, body=compacted)
|
|
38
|
+
|
|
39
|
+
def get(self, id: str) -> Any:
|
|
40
|
+
"""Fetch the current status of an audio-to-video task."""
|
|
41
|
+
return self._request("get", f"{self.ENDPOINT}/{id}")
|
|
42
|
+
|
|
43
|
+
def _validate_params(self, params: Dict[str, Any]) -> None:
|
|
44
|
+
model = params.get("model")
|
|
45
|
+
if not model:
|
|
46
|
+
raise ValidationError("model is required")
|
|
47
|
+
if model not in MODELS:
|
|
48
|
+
joined = ", ".join(MODELS)
|
|
49
|
+
raise ValidationError(f"Invalid model: {model}. Must be one of: {joined}")
|
|
50
|
+
|
|
51
|
+
self._validate_required(params, "source_image_url")
|
|
52
|
+
self._validate_required(params, "source_audio_url")
|
|
53
|
+
|
|
54
|
+
prompt = params.get("prompt")
|
|
55
|
+
if not (isinstance(prompt, str) and prompt != ""):
|
|
56
|
+
raise ValidationError("prompt is required")
|
|
57
|
+
if len(prompt) > PROMPT_MAX_LENGTH:
|
|
58
|
+
raise ValidationError(f"prompt must be at most {PROMPT_MAX_LENGTH} characters")
|
|
59
|
+
|
|
60
|
+
self._validate_optional(params, "output_resolution", RESOLUTIONS)
|
|
61
|
+
|
|
62
|
+
seed = params.get("seed")
|
|
63
|
+
if seed is None:
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
parsed = self._parse_integer(seed)
|
|
67
|
+
if parsed is not None and parsed in SEED_RANGE:
|
|
68
|
+
return
|
|
69
|
+
|
|
70
|
+
raise ValidationError(
|
|
71
|
+
f"seed must be an integer between {SEED_RANGE.start} and {SEED_RANGE.stop - 1}"
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
@staticmethod
|
|
75
|
+
def _validate_required(params: Dict[str, Any], key: str) -> None:
|
|
76
|
+
value = params.get(key)
|
|
77
|
+
present = (value != "") if isinstance(value, str) else (value is not None)
|
|
78
|
+
if not present:
|
|
79
|
+
raise ValidationError(f"{key} is required")
|
|
80
|
+
|
|
81
|
+
@staticmethod
|
|
82
|
+
def _parse_integer(value: Any) -> Any:
|
|
83
|
+
"""Mirror Ruby ``Integer(value, exception: false)``.
|
|
84
|
+
|
|
85
|
+
Accepts ints and integer-looking strings; rejects bools and anything
|
|
86
|
+
non-coercible by returning ``None``.
|
|
87
|
+
"""
|
|
88
|
+
if isinstance(value, bool):
|
|
89
|
+
return None
|
|
90
|
+
if isinstance(value, int):
|
|
91
|
+
return value
|
|
92
|
+
if isinstance(value, str):
|
|
93
|
+
try:
|
|
94
|
+
return int(value.strip(), 10)
|
|
95
|
+
except ValueError:
|
|
96
|
+
return None
|
|
97
|
+
return None
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""InfiniteTalk model lists, enums, and response models."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from runapi.core import BaseModel, TaskResponse, optional, required
|
|
6
|
+
|
|
7
|
+
MODELS = ["infinitetalk-from-audio"]
|
|
8
|
+
RESOLUTIONS = ["480p", "720p"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Video(BaseModel):
|
|
12
|
+
url = optional(str)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class AudioToVideoResponse(TaskResponse):
|
|
16
|
+
"""Response for an audio-to-video task."""
|
|
17
|
+
|
|
18
|
+
id = required(str)
|
|
19
|
+
status = optional(str, enum=lambda: TaskResponse.Status.ALL)
|
|
20
|
+
videos = optional([lambda: Video])
|
|
21
|
+
error = optional(str)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class CompletedAudioToVideoResponse(AudioToVideoResponse):
|
|
25
|
+
"""Returned by ``audio_to_video.run()`` once polling observes completion.
|
|
26
|
+
|
|
27
|
+
``videos`` is required so callers never have to null-check it on success.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
videos = required([lambda: Video])
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: runapi-infinitetalk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: InfiniteTalk audio-to-video client for RunAPI
|
|
5
|
+
Project-URL: Homepage, https://runapi.ai/models/infinitetalk
|
|
6
|
+
Project-URL: Documentation, https://runapi.ai/docs#sdk-infinitetalk
|
|
7
|
+
Author-email: RunAPI <contact@runapi.ai>
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
Keywords: ai,audio-to-video,infinitetalk,runapi,sdk
|
|
10
|
+
Requires-Python: >=3.9
|
|
11
|
+
Requires-Dist: runapi-core
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
|
|
14
|
+
# InfiniteTalk Python SDK for RunAPI
|
|
15
|
+
|
|
16
|
+
The InfiniteTalk Python SDK is the language-specific package for InfiniteTalk on
|
|
17
|
+
RunAPI. Use it for audio-to-video flows when your application needs JSON request
|
|
18
|
+
bodies, task status lookup, and consistent RunAPI errors in Python.
|
|
19
|
+
|
|
20
|
+
For model details, use https://runapi.ai/models/infinitetalk; for API reference,
|
|
21
|
+
use https://runapi.ai/docs#infinitetalk; for SDK docs, use
|
|
22
|
+
https://runapi.ai/docs#sdk-infinitetalk.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install runapi-infinitetalk
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick start
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from runapi.infinitetalk import InfinitetalkClient
|
|
34
|
+
|
|
35
|
+
client = InfinitetalkClient() # reads RUNAPI_API_KEY, or pass api_key="sk-..."
|
|
36
|
+
|
|
37
|
+
task = client.audio_to_video.create(
|
|
38
|
+
model="infinitetalk-from-audio",
|
|
39
|
+
source_image_url="https://example.com/face.jpg",
|
|
40
|
+
source_audio_url="https://example.com/voice.mp3",
|
|
41
|
+
prompt="A person speaking to the camera",
|
|
42
|
+
output_resolution="720p",
|
|
43
|
+
)
|
|
44
|
+
status = client.audio_to_video.get(task.id)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Use `create` to submit a task and return quickly, `get` to fetch the latest task
|
|
48
|
+
state, and `run` to create and poll until completion:
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
result = client.audio_to_video.run(
|
|
52
|
+
model="infinitetalk-from-audio",
|
|
53
|
+
source_image_url="https://example.com/face.jpg",
|
|
54
|
+
source_audio_url="https://example.com/voice.mp3",
|
|
55
|
+
prompt="A person speaking to the camera",
|
|
56
|
+
)
|
|
57
|
+
print(result.videos[0].url)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
In web request handlers, prefer `create` plus webhook or later `get` polling so a
|
|
61
|
+
worker is not held open.
|
|
62
|
+
|
|
63
|
+
RunAPI-generated file URLs are temporary. Download and store generated videos in
|
|
64
|
+
your own durable storage within 7 days; do not treat returned URLs as long-term
|
|
65
|
+
assets.
|
|
66
|
+
|
|
67
|
+
## Language notes
|
|
68
|
+
|
|
69
|
+
Pass parameters as keyword arguments and catch the `runapi.infinitetalk` error
|
|
70
|
+
classes when building video jobs or scripts. The available resource is
|
|
71
|
+
`audio_to_video`. Keep `RUNAPI_API_KEY` in the environment or your secret
|
|
72
|
+
manager; never commit API keys or callback secrets.
|
|
73
|
+
|
|
74
|
+
## Links
|
|
75
|
+
|
|
76
|
+
- Model page: https://runapi.ai/models/infinitetalk
|
|
77
|
+
- SDK docs: https://runapi.ai/docs#sdk-infinitetalk
|
|
78
|
+
- Product docs: https://runapi.ai/docs#infinitetalk
|
|
79
|
+
- Pricing and rate limits: https://runapi.ai/models/infinitetalk
|
|
80
|
+
- Full catalog: https://runapi.ai/models
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
Licensed under the Apache License, Version 2.0.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
runapi/infinitetalk/__init__.py,sha256=4cPrG0fhkeyGzHjsFr_LoiI1PeDFLQ1uTYuEar42uec,478
|
|
2
|
+
runapi/infinitetalk/client.py,sha256=7rEmhBiK4hlh75sKm3CYbj7NVBPGKv3LFujkcUtHV7g,971
|
|
3
|
+
runapi/infinitetalk/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
runapi/infinitetalk/types.py,sha256=xUk_1uLaLMrKalHWSqHslz5NgGROlzpqk8KX9Y9QXXg,795
|
|
5
|
+
runapi/infinitetalk/resources/__init__.py,sha256=OOyb5FAx8o69_pGxula1UXROTNEbobzXQIR2JZmlXe4,69
|
|
6
|
+
runapi/infinitetalk/resources/audio_to_video.py,sha256=o7LKrPmQ7SimJ3YvAgwWOBG8ZdhEKEkpVImWqOjJwxo,3253
|
|
7
|
+
runapi_infinitetalk-0.1.0.dist-info/METADATA,sha256=GeLVdI0QWyO23p_5Av9g3NQm0jZXph1auWIg-Yqo5co,2751
|
|
8
|
+
runapi_infinitetalk-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
9
|
+
runapi_infinitetalk-0.1.0.dist-info/RECORD,,
|