mirror of
https://github.com/Paillat-dev/viralfactory.git
synced 2026-01-02 09:16:19 +00:00
🐛 fix(GenerationContext.py): fix import statements and add support for captioning engine
✨ feat(GenerationContext.py): add support for captioning engine in the GenerationContext class
The import statement for the `moviepy.editor` module is changed to `moviepy.editor as mp` to improve code readability. Additionally, the `gradio` module is imported as `gr` to improve code readability. The `GenerationContext` class now includes a `captioningengine` parameter and initializes a `captioningengine` attribute. The `setup_dir` method is modified to include a call to create a directory for the output files. The `get_file_path` method is modified to return the file path based on the output directory. The `process` method is modified to include additional steps for captioning. The `timed_script` attribute is added to store the result of the `ttsengine.synthesize` method. The `captioningengine` is used to generate captions and store them in the `captions` attribute. The final video is rendered using the `moviepy` library and saved as "final.mp4" in the output directory.
This commit is contained in:
@@ -8,10 +8,15 @@ class Prompt(TypedDict):
|
||||
chat: str
|
||||
|
||||
|
||||
def get_prompt(name, *, location="src/chore/prompts") -> tuple[str, str]:
|
||||
path = os.path.join(os.getcwd(), location, f"{name}.yaml")
|
||||
def get_prompt(name, *, location: str="src/chore/prompts", by_file_location: str = None) -> tuple[str, str]:
|
||||
if by_file_location:
|
||||
path = os.path.join(
|
||||
os.path.dirname(os.path.abspath(by_file_location)), "prompts", f"{name}.yaml"
|
||||
)
|
||||
else:
|
||||
path = os.path.join(os.getcwd(), location, f"{name}.yaml")
|
||||
if not os.path.exists(path):
|
||||
raise FileNotFoundError(f"Prompt file {path} does not exist.")
|
||||
with open(path, "r") as file:
|
||||
prompt: Prompt = yaml.safe_load(file)
|
||||
return prompt["system"], prompt["chat"]
|
||||
return prompt["system"], prompt["chat"]
|
||||
|
||||
Reference in New Issue
Block a user