Spaces:
Paused
Paused
Download app/characters.py from modventures/mod-higgsfield: direct link, hf CLI and curl.
- Browser
- Download file 1.29 kB
-
https://huggingface.co/spaces/modventures/mod-higgsfield/resolve/main/app/characters.py
- Command line
-
hf download hf://spaces/modventures/mod-higgsfield/app/characters.py
-
curl -L -o characters.py https://huggingface.co/spaces/modventures/mod-higgsfield/resolve/main/app/characters.py
1.29 kB
| """Seeded characters: one directory each, holding the face photo and the voice sample.""" | |
| import json | |
| from pathlib import Path | |
| FILES = ('character.json', 'face.png', 'voice.wav', 'voice.txt') | |
| class Characters: | |
| def __init__(self, root): | |
| self.items = {} | |
| root = Path(root) | |
| for directory in sorted(p for p in root.iterdir() if p.is_dir()) if root.is_dir() else []: | |
| missing = [name for name in FILES if not (directory / name).is_file()] | |
| if missing: | |
| raise ValueError(f'Character {directory.name} is missing {", ".join(missing)}') | |
| info = json.loads((directory / 'character.json').read_text()) | |
| self.items[directory.name] = { | |
| 'id': directory.name, 'name': info['name'], | |
| # Describes the on-camera look and setting; conditions the talking-head model. | |
| 'appearance': info['appearance'], | |
| 'face': directory / 'face.png', 'voice': directory / 'voice.wav', | |
| 'voice_text': (directory / 'voice.txt').read_text().strip()} | |
| def get(self, character_id): | |
| return self.items.get(character_id) | |
| def public(self): | |
| return [{'id': c['id'], 'name': c['name'], 'appearance': c['appearance']} for c in self.items.values()] | |