EmojiVidGen 是一个有趣的工具,可以从文本文件创建视频。它接受包含脚本(类似于故事或对话)的纯文本文件形式的输入。然后,它将这个脚本转换成令人惊叹的视频。 EmojiVidGen 基于插件系统,允许尝试不同的模型和语言。您所需要的只是一些想象力和打字技巧!
主要特点
虽然 EmojiVidGen 最初旨在用于 GenAI 的娱乐,但EmojiVidGen
在制作引人入胜且炫酷的内容方面拥有巨大的潜力,尤其是在有能力的人手中。该项目是实验性的,主要用于教育目的,探索人工智能驱动的视频创作的可能性。
该软件仅用于教育目的。您自行决定使用它并承担风险。请注意,本代码中使用的人工智能模型可能对商业用途有限制。
sudo apt update
sudo apt install espeak ffmpeg
git clone https://github.com/code2k13/emoji_vid_gen
cd emoji_vid_gen
wget https://github.com/googlefonts/noto-emoji/raw/main/fonts/NotoColorEmoji.ttf
pip install -r requirements.txt
注意:脚本应始终以
Image:
指令开头
Image: Cartoon illustration showing a beautiful landscape with mountains and a road.
Audio: Tranquil calm music occasional chirping of birds.
Title: EmojiVidGen
?: Emoji vid gen is a tool to create videos from text files using AI.
python generate_video.py stories/hello.txt hello.mp4
Image: A single trophy kept on table. comic book style.
Audio: Upbeat introduction music for cartoon show.
Title: Emoji Quiz Showdown
?: " Welcome to the Emoji Quiz Showdown! Are you ready to test your knowledge? "
?: " Meow! I'm ready! "
?: " Woof! Let's do this! "
Image: Cartoon illustration of the Eiffel Tower.
?: " First question What is the capital of France? "
Audio: suspenseful music playing.
?: " Paris! "
Audio: people applauding sound
Image: Cartoon illustration of Mount Everest.
?: " Correct! One point for the cat! Next question What is the tallest mountain in the world? "
Audio: suspenseful music playing.
?: " Mount Everest! "
Audio: people applauding sound
Image: Cartoon illustration of a water molecule.
?: " Right again! One point for the dog! Next question What is the chemical symbol for water? "
Audio: suspenseful music playing.
?: " H2O! "
Audio: people applauding sound
Image: Cartoon illustration of a globe with seven continents.
?: " Correct! Another point for the cat! Last question How many continents are there on Earth? "
Audio: suspenseful music playing.
?: " Seven! "
Audio: people applauding sound
?: " Correct! It's a tie! You both did great! Thanks for playing the Emoji Quiz Showdown! "
表情符号?️
被保留为旁白。在行首使用它会导致系统仅生成声音而不在背景上输出任何图像。
如果您按照前面的视频生成说明进行操作,您可能会注意到默认设置使用espeak
作为文本转语音引擎,从而产生机械声音输出。 EmojiVidGen 采用由插件组成的内部结构构建,每个插件都能够修改任务的执行方式或使用的模型。
例如,您可以为每种类型的生成任务指定特定的插件 - 无论是文本到图像、文本到音频还是文本到语音。由于每个插件都以其独特的模型和方法运行,因此单独配置这些设置可能会让人不知所措。为了简化这个过程,我引入了预设的概念。您可以通过向generate_video.py
文件提供--preset
选项来应用预设。
例如,下面的预设使用名为local_medium
预设。
python generate_video.py stories/hello.txt hello.mp4 --preset local_medium
所有预设都存储在./presets folder
中。要创建新的预设(例如custom_preset
),只需在“./presets”文件夹中创建一个新的custom_preset.yaml
文件并开始像这样使用它
python generate_video.py stories/hello.txt hello.mp4 --preset custom_preset
请注意, characters
部分中使用的voice
应受所选text_to_speech
提供程序的支持。理想情况下,图像应为具有方形长宽比和透明背景的 PNG 文件。
预设名称 | 描述 |
---|---|
openai_basic | 使用 OpenAI 进行文本转语音(标准)和图像生成 (DALL-E 2 @ 512x512)。需要填充OPENAI_API_KEY 环境变量 |
openai_medium | 与 openai_basic 类似,但使用 (DALL-E 3 @ 1024x1024)。需要填充OPENAI_API_KEY 环境变量 |
本地基本 | 使用 Huggingface 的稳定扩散管道和stabilityai/sd-turbo 模型将文本转换为图像。使用espeak 进行文本转语音,使用 Huggingface 的 AudioLDM 管道进行文本转音频。 |
本地基本GPU | 与 local_basic 相同,但启用了 cuda 支持。 |
本地媒体 | 与 local_basic 类似,但使用brave 作为文本转语音引擎,使用stabilityai/sdxl-turbo 模型进行文本转图像 |
本地媒体 | 与 local_medium 相同,但启用了 cuda 支持。 |
十一_中 | 与 local_medium 相同,但启用了ElevenLabs 文本转语音 API 支持。需要在.env 文件中定义互联网和ELEVEN_API_KEY 变量。需要互联网和 ElevenLabs 帐户。 |
对话者中型 | 与 local_medium 相同,但启用了使用parler 文本转语音 API 支持。 |
有时您可能不想在视频中使用表情符号作为角色,或者为每个角色使用不同的声音。现在可以使用预设 yaml 文件中的characters
部分来实现这一点。下面给出了此类部分的示例:
global :
width : 512
height : 512
use_cuda : " false "
characters :
- name : " ? "
voice : " fable "
- name : " ? "
image : " /workspace/emoji_vid_gen/cat.png "
voice : " alloy "
- name : " ? "
image : " /workspace/emoji_vid_gen/dog.png "
voice : " echo "
text_to_speech :
provider : openai
voice : Nova
在制品
EmojiVidGen 利用缓存机制来保留视频创建过程中生成的资源,每个资源都与所使用的特定“提示”相关联。事实证明,此功能非常有用,尤其是在迭代优化视频时,无需重复重新生成资产。但请注意, .cache
目录不会自动清除。建议在完成一个视频项目并开始另一个视频项目时清除它。
提示:要强制重新创建缓存资源,请对“提示”进行较小的更改,例如添加空格或标点符号
确保资源文件存在于.cache
文件夹中。以这种方式创建脚本
Image: .cache/existing_background_hd.png
Audio: Funny opening music jingle.
Title: EmojiVidGen
?: .cache/existing_speech.wav
复制合适的预设文件并修改以下行:
global :
width : 1152
height : 896
注意:此设置确实会影响稳定扩散的输出。并不是所有的决议都那么有效。有关更多信息,请查看此 https://replicate.com/guides/stable-diffusion/how-to-use/ 。稳定扩散似乎适用于方形纵横比。
使用espeak
文本转语音提供程序时,您将看到此错误消息。
Traceback (most recent call last):
File " /usr/local/lib/python3.10/dist-packages/pyttsx3/drivers/espeak.py " , line 171, in _onSynth
self._proxy.notify( ' finished-utterance ' , completed=True)
ReferenceError: weakly-referenced object no longer exists
暂时忽略此错误,因为它不会影响输出。
如果收到以下错误,请删除.cache
目录
File " plyvel/_plyvel.pyx " , line 247, in plyvel._plyvel.DB.__init__
File " plyvel/_plyvel.pyx " , line 88, in plyvel._plyvel.raise_for_status
plyvel._plyvel.IOError: b ' IO error: lock .cache/asset/LOCK: Resource temporarily unavailable '
@misc{lacombe-etal-2024-parler-tts,
author = {Yoach Lacombe and Vaibhav Srivastav and Sanchit Gandhi},
title = {Parler-TTS},
year = {2024},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {url{https://github.com/huggingface/parler-tts}}
}
@misc{lyth2024natural,
title={Natural language guidance of high-fidelity text-to-speech with synthetic annotations},
author={Dan Lyth and Simon King},
year={2024},
eprint={2402.01912},
archivePrefix={arXiv},
primaryClass={cs.SD}
}