Go to OpenArt main site
Upload workflow

AI Dialogue Game <Journey to the West>

5.0

16 reviews
151
21.6K
3.9K
7
Description

What this workflow does
You can build an interactive, real-time dialogue game in ComfyUI with the theme of the Chinese mythological story "Journey to the West." You play as the newly born Monkey King, Sun Wukong.
GPT is responsible for scriptwriting, SDXL and Dall.E3 for creating the illustrations, and MS-TTS for delivering the spoken dialogues in various voices. After the whole process of arranging and designing, everything is presented as a scroll painting right before your eyes.
You make choices from the 4 options provided by GPT and the game continues to unfold. You're free to alter the storyline as GPT accompanies you throughout, turning your imagination into stunning visuals.


How to use this workflow
Simply type "StartGame" in the input box, and the game will start from your birth. Follow the plot and input your choices.


๐ŸŽฅ Video demo link
I've recorded a video demonstrating game operations: https://youtu.be/-ppWmbC38aI
ๅ…„ๅผŸไปฌ๏ผŒไธญๆ–‡ๆผ”็คบ็œ‹่ฟ™้‡Œ: https://www.bilibili.com/video/BV1sw411h7A5

The background Pic Link:

https://drive.google.com/drive/folders/1kNT9N-jt6qQZ0wuUgolPsRDSW3EEy6T8?usp=sharing


The entire workflow is divided into 12 modules and I will explain each one in detail:

1. StoryLine-GPT
This module utilizes the GPT node from MixLab. It's responsible for calling GPT's API, uploading the written Prompt, and letting GPT complete the story writing and providing new options to the player. This is the core of the game.
You can see the set Prompt in "Story-Prompt". It's still crude, but sufficient to start the game, and I will continue to refine it.
"ShowText" displays the text returned from GPT, which will be shown to the player, including a short description of the current plot and four options.
The "PlaySound" will make a beep when the output is completed, since the whole process is long this sound will remind you that the story writing work is finished. Similar beeps are also set up in modules 2 and 5. When you hear three beeps, it means the new game image will appear soon.

MIiXLab: https://github.com/shadowcz007/comfyui-mixlab-nodes
To use this node you need to enter your OpenAI API in the first input box, which you can obtain from the official OpenAI website. In the second input box, enter the URL: https://api.openai.com/v1
Choose Model: gpt-4-1106-preview
You can fill in any Seed, but changing the Seed means starting a new conversation with clear memory.
Control_after_generate: Choose 'Fixed' so that GPT can remember and continue the storyline.

As far as I know, this is the only GPT node in ComfyUI that supports this memory function. Its developer, Shadow, is rapidly updating its capabilities, so make sure you're using the latest version.

If you don't have the GPT API, you can also use a locally deployed GLM model as an alternative. You can find the relevant instructions on the MixLab page.


2. Prompt-GPT
The function of this module is exactly the same as module 1, but it transforms the story written by module 1 into illustrative painting prompts for use in SDXL.


3. TTS
Uses "MSSpeech_TTS" to read the story output of module 1.
The rate is the speed of narration. The node saves the generated speech in the ComfyUI folder and outputs the path.
The "Play Sound" node takes care of mp3 playback and is triggered by an Image node.
I used AnyWhere to transmit image information, which is triggered when the final image is ready (you can find it in module 9).
MSSpeech_TTS: https://github.com/chflame163/ComfyUI_MSSpeech_TTS

Comfyroll_CustomNodes๏ผš https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes


4. BG-Music
Uses "Play Sound (loop) " node to play local music.
I'm using it for two Play nodes, node #1 will play the background music from the start, and a short sound effect is prevented in node #2, so when you want to stop the music, just turn on node #2 and run the workflow once.

Download link for the audio file played here:

https://drive.google.com/drive/folders/1kNT9N-jt6qQZ0wuUgolPsRDSW3EEy6T8?usp=sharing


5. SDXL
Uses the prompt input from module 2 to draw the game image.
The model I used is: starlightXLAnimated_v2

https://civitai.com/models/143043/starlight-xl-animated


6. Dall.E3
I used Dall.E3 as an alternative to the drawing model, connected to the Dall.E3 API using the "ComfyUI-NegiTools" node.
Friendly reminder: this is very expensive, but the results are excellent.
NegiTools: https://github.com/natto-maki/ComfyUI-NegiTools


7. Model Choose
This module is used to make a choice between SDXL and Dall.E3.


8. WaterMarks
The ZHO text node is used to write copyright information on the image. There are many nodes for calculating coordinates, but you don't need to worry about them. Just use the green nodes.
You can enter any text you want to display in "Text".
Text_Image-Composite: https://github.com/ZHO-ZHO-ZHO/ComfyUI-Text_Image-Composite


9. Text to Image
The story text output from module 1 is converted into an image for display on the right side of the final image.
The same text node as in module 8 is used here.


10. Layout
All images are assembled together.
I created a background image, a Chinese-style scroll. At the top and bottom of the image, I placed the game logo: BG.jpg.
Then I pasted the game image drawn in module 3 on the left side of the scroll. To blend the image and scroll naturally, I created a Border Mask on top: Mask.png.
Finally, the story text image output from module 9 was pasted on the right side of the image.
After completing all the integrations, I output via AnythingAnywhere.
In modules 3 and 12, there will be nodes to receive this.
Here, I used SaveImage to store the image, to use the more concise PreViewImage node for the final display.


11. Save Text
All the story text output from module 1 will be summarized here and stored in the out folder of ComfyUI, with the file name being the date in format 'date.txt'.


12. Game Screen
The final display to the player, with a text input box at the bottom for the player to input commands.

Initially you can enter: Start Game


โ€”โ€”โ€”โ€”โ€”โ€”
Other nodes used:

QualityOfLifeSuit_Omar92

https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92

Custom-Scripts๏ผˆpysssss๏ผ‰

https://github.com/pythongosssss/ComfyUI-Custom-Scripts

sdxl_prompt_styler

https://github.com/twri/sdxl_prompt_styler

ComfyMath

https://github.com/evanspearman/ComfyMath

Derfuu_ComfyUI

https://github.com/Derfuu/Derfuu_ComfyUI_ModdedNodes

Comfyroll Custom Nodes

https://github.com/RockOfFire/ComfyUI_Comfyroll_CustomNodes

Stability-ComfyUI-nodes

https://github.com/twri/sdxl_prompt_styler

Effciency Nodes

https://github.com/LucianoCirino/efficiency-nodes-comfyui

Everywhere:

https://github.com/chrisgoringe/cg-use-everywhere

By Rui @12-6-2023

Tips about this workflow

AI Game๏ผŒDialogue Game๏ผŒreal-time painting, API, GPT



Discussion

(No comments yet)

Loading...

Author

13
116.7K
2.6K
466.6K

No reviews yet

  • - latest (a year ago)

  • - v20231206-173138

  • - v20231206-155805

Primitive Nodes (13)

Anything Everywhere (1)

Int to float (4)

Note (1)

Play Sound (loop) (2)

Reroute (5)

Custom Nodes (62)

ComfyMath

  • - CM_FloatBinaryOperation (6)

  • - CR Float To Integer (2)

  • - CR Image Output (1)

ComfyUI

  • - PreviewImage (3)

  • - SaveImage (3)

  • - LoadImage (2)

  • - SplitImageWithAlpha (2)

  • - CLIPTextEncode (2)

  • - EmptyLatentImage (1)

  • - ImageScaleBy (1)

  • - JoinImageWithAlpha (1)

  • - VAEDecode (1)

  • - VAELoader (1)

  • - KSampler (1)

  • - PatchModelAddDownscale (1)

  • - MicrosoftSpeech_TTS (1)

  • - Play Sound (1)

  • - Float (1)

  • - ChatGPTOpenAI (2)

  • - NegiTools_OpenAiDalle3 (1)

  • - Text_Image_Multiline_Zho (2)

  • - LoraLoader|pysssss (1)

  • - PlaySound|pysssss (3)

  • - ShowText|pysssss (3)

  • - SaveText|pysssss (1)

  • - CheckpointLoader|pysssss (1)

  • - Concat Text _O (3)

  • - Text _O (6)

  • - SDXLPromptStyler (2)

  • - GetImageSize (2)

Checkpoints (1)

SDXL\starlightXLAnimated_v2.safetensors

LoRAs (1)

Sdxl\sdxl_offset_example_v10.safetensors