EmojiVidGen は、テキスト ファイルからビデオを作成する楽しいツールです。スクリプト (ストーリーや対話に似たもの) を含むプレーン テキスト ファイルの形式で入力を受け取ります。次に、このスクリプトを素晴らしいビデオに変換します。 EmojiVidGen はプラグイン システムに基づいており、さまざまなモデルや言語を試すことができます。必要なのは想像力とタイピングのスキルだけです。
主な特長
EmojiVidGen
当初 GenAI を使ったエンターテイメントを目的としていましたが、特に有能な人材であれば、魅力的でクールなコンテンツを作成できる大きな可能性を秘めています。このプロジェクトは実験的なもので、主に教育目的で作成され、AI を活用したビデオ作成の可能性を探ります。
このソフトウェアは教育目的のみを目的としています。ご自身の判断と責任においてご使用ください。このコードで利用されている AI モデルには商用利用に対する制限がある場合があることに注意してください。
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_基本 | テキスト読み上げ (標準) と画像生成 (DALL-E 2 @ 512x512) に OpenAI を使用します。 OPENAI_API_KEY 環境変数を設定する必要があります |
openai_medium | openai_basic に似ていますが、(DALL-E 3 @ 1024x1024) を使用します。 OPENAI_API_KEY 環境変数を設定する必要があります |
ローカル_基本 | テキストから画像へのstabilityai/sd-turbo モデルを備えたHuggingfaceの安定した拡散パイプラインを使用します。テキストから音声への変換にはespeak 使用し、テキストから音声への変換には Huggingface の AudioLDM パイプラインを使用します。 |
local_basic_gpu | local_basic と同じですが、cuda サポートが有効になっています。 |
ローカル_ミディアム | local_basic に似ていますが、テキスト読み上げエンジンとしてbrave を使用し、テキストから画像へのstabilityai/sdxl-turbo モデルを使用します。 |
ローカル_ミディアム | local_medium と同じですが、cuda サポートが有効になっています。 |
イレブン_ミディアム | local_medium と同じですが、 ElevenLabs テキスト読み上げ API サポートが有効になっています。インターネットとELEVEN_API_KEY 変数を.env ファイルで定義する必要があります。インターネットと イレブンラボのアカウントが必要です。 |
パーラー_ミディアム | 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
WIP
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}
}