Spaces:
Build error
Build error
apply systematic btn en/disable in chargen->storygen
Browse files- app.py +191 -15
- interfaces/story_gen_ui.py +49 -13
app.py
CHANGED
@@ -266,7 +266,7 @@ with gr.Blocks(css=STYLE) as demo:
|
|
266 |
story_writing_done_btn = gr.Button("export your story β", elem_classes=["wrap", "control-button"], scale=2)
|
267 |
|
268 |
with gr.Column(visible=False) as export_phase:
|
269 |
-
gr.Markdown("# π€
|
270 |
gr.Markdown(desc.export_phase_description, elem_classes=["markdown-justify"])
|
271 |
|
272 |
title_txt = gr.Textbox("Your Own Story", elem_classes=["no-label"])
|
@@ -416,6 +416,16 @@ with gr.Blocks(css=STYLE) as demo:
|
|
416 |
view_change_ui.move_to_next_view,
|
417 |
inputs=None,
|
418 |
outputs=[character_setup_phase, writing_phase]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
).then(
|
420 |
story_gen_ui.first_story_gen,
|
421 |
inputs=[
|
@@ -443,9 +453,29 @@ with gr.Blocks(css=STYLE) as demo:
|
|
443 |
outputs=[
|
444 |
action_btn1, action_btn2, action_btn3, progress_comp
|
445 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
446 |
)
|
447 |
|
448 |
regen_actions_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
449 |
story_gen_ui.actions_gen,
|
450 |
inputs=[
|
451 |
cursors,
|
@@ -458,9 +488,29 @@ with gr.Blocks(css=STYLE) as demo:
|
|
458 |
outputs=[
|
459 |
action_btn1, action_btn2, action_btn3, progress_comp
|
460 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
461 |
)
|
462 |
|
463 |
regen_story_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
464 |
story_gen_ui.update_story_gen,
|
465 |
inputs=[
|
466 |
cursors, cur_cursor,
|
@@ -486,6 +536,16 @@ with gr.Blocks(css=STYLE) as demo:
|
|
486 |
outputs=[
|
487 |
action_btn1, action_btn2, action_btn3, progress_comp
|
488 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
)
|
490 |
|
491 |
#### Setups
|
@@ -552,24 +612,74 @@ with gr.Blocks(css=STYLE) as demo:
|
|
552 |
)
|
553 |
|
554 |
image_gen_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
story_gen_ui.image_gen,
|
556 |
inputs=[
|
557 |
-
genre_dd, place_dd, mood_dd, title, story_content, cursors, cur_cursor
|
558 |
],
|
559 |
outputs=[
|
560 |
-
story_image,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
]
|
562 |
)
|
563 |
|
564 |
audio_gen_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
565 |
story_gen_ui.audio_gen,
|
566 |
inputs=[
|
567 |
-
genre_dd, place_dd, mood_dd, title, story_content, cursors, cur_cursor
|
568 |
],
|
569 |
-
outputs=[story_audio,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
570 |
)
|
571 |
|
572 |
img_audio_combine_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
story_gen_ui.video_gen,
|
574 |
inputs=[
|
575 |
story_image, story_audio, story_content, cursors, cur_cursor
|
@@ -577,7 +687,17 @@ with gr.Blocks(css=STYLE) as demo:
|
|
577 |
outputs=[
|
578 |
story_image, story_audio, story_video, cursors, progress_comp
|
579 |
],
|
580 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
581 |
|
582 |
story_progress.input(
|
583 |
story_gen_ui.move_story_cursor,
|
@@ -594,10 +714,14 @@ with gr.Blocks(css=STYLE) as demo:
|
|
594 |
)
|
595 |
|
596 |
action_btn1.click(
|
597 |
-
|
598 |
inputs=None,
|
599 |
outputs=[
|
600 |
-
image_gen_btn, audio_gen_btn, img_audio_combine_btn
|
|
|
|
|
|
|
|
|
601 |
]
|
602 |
).then(
|
603 |
story_gen_ui.next_story_gen,
|
@@ -629,13 +753,27 @@ with gr.Blocks(css=STYLE) as demo:
|
|
629 |
outputs=[
|
630 |
action_btn1, action_btn2, action_btn3, progress_comp
|
631 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
632 |
)
|
633 |
|
634 |
action_btn2.click(
|
635 |
-
|
636 |
inputs=None,
|
637 |
outputs=[
|
638 |
-
image_gen_btn, audio_gen_btn, img_audio_combine_btn
|
|
|
|
|
|
|
|
|
639 |
]
|
640 |
).then(
|
641 |
story_gen_ui.next_story_gen,
|
@@ -667,13 +805,27 @@ with gr.Blocks(css=STYLE) as demo:
|
|
667 |
outputs=[
|
668 |
action_btn1, action_btn2, action_btn3, progress_comp
|
669 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
670 |
)
|
671 |
|
672 |
action_btn3.click(
|
673 |
-
|
674 |
inputs=None,
|
675 |
outputs=[
|
676 |
-
image_gen_btn, audio_gen_btn, img_audio_combine_btn
|
|
|
|
|
|
|
|
|
677 |
]
|
678 |
).then(
|
679 |
story_gen_ui.next_story_gen,
|
@@ -705,13 +857,27 @@ with gr.Blocks(css=STYLE) as demo:
|
|
705 |
outputs=[
|
706 |
action_btn1, action_btn2, action_btn3, progress_comp
|
707 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
708 |
)
|
709 |
|
710 |
custom_action_txt.submit(
|
711 |
-
|
712 |
inputs=None,
|
713 |
outputs=[
|
714 |
-
image_gen_btn, audio_gen_btn, img_audio_combine_btn
|
|
|
|
|
|
|
|
|
715 |
]
|
716 |
).then(
|
717 |
story_gen_ui.next_story_gen,
|
@@ -743,6 +909,16 @@ with gr.Blocks(css=STYLE) as demo:
|
|
743 |
outputs=[
|
744 |
action_btn1, action_btn2, action_btn3, progress_comp
|
745 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
746 |
)
|
747 |
|
748 |
### Chatbot
|
@@ -801,4 +977,4 @@ with gr.Blocks(css=STYLE) as demo:
|
|
801 |
outputs=[selected_side_char_image3]
|
802 |
)
|
803 |
|
804 |
-
demo.queue().launch()
|
|
|
266 |
story_writing_done_btn = gr.Button("export your story β", elem_classes=["wrap", "control-button"], scale=2)
|
267 |
|
268 |
with gr.Column(visible=False) as export_phase:
|
269 |
+
gr.Markdown("# π€ Export your story")
|
270 |
gr.Markdown(desc.export_phase_description, elem_classes=["markdown-justify"])
|
271 |
|
272 |
title_txt = gr.Textbox("Your Own Story", elem_classes=["no-label"])
|
|
|
416 |
view_change_ui.move_to_next_view,
|
417 |
inputs=None,
|
418 |
outputs=[character_setup_phase, writing_phase]
|
419 |
+
).then(
|
420 |
+
story_gen_ui.disable_btns,
|
421 |
+
inputs=None,
|
422 |
+
outputs=[
|
423 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
424 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
425 |
+
action_btn1, action_btn2, action_btn3,
|
426 |
+
custom_action_txt,
|
427 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
428 |
+
]
|
429 |
).then(
|
430 |
story_gen_ui.first_story_gen,
|
431 |
inputs=[
|
|
|
453 |
outputs=[
|
454 |
action_btn1, action_btn2, action_btn3, progress_comp
|
455 |
]
|
456 |
+
).then(
|
457 |
+
story_gen_ui.enable_btns,
|
458 |
+
inputs=[story_image, story_audio],
|
459 |
+
outputs=[
|
460 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
461 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
462 |
+
action_btn1, action_btn2, action_btn3,
|
463 |
+
custom_action_txt,
|
464 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
465 |
+
]
|
466 |
)
|
467 |
|
468 |
regen_actions_btn.click(
|
469 |
+
story_gen_ui.disable_btns,
|
470 |
+
inputs=None,
|
471 |
+
outputs=[
|
472 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
473 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
474 |
+
action_btn1, action_btn2, action_btn3,
|
475 |
+
custom_action_txt,
|
476 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
477 |
+
]
|
478 |
+
).then(
|
479 |
story_gen_ui.actions_gen,
|
480 |
inputs=[
|
481 |
cursors,
|
|
|
488 |
outputs=[
|
489 |
action_btn1, action_btn2, action_btn3, progress_comp
|
490 |
]
|
491 |
+
).then(
|
492 |
+
story_gen_ui.enable_btns,
|
493 |
+
inputs=[story_image, story_audio],
|
494 |
+
outputs=[
|
495 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
496 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
497 |
+
action_btn1, action_btn2, action_btn3,
|
498 |
+
custom_action_txt,
|
499 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
500 |
+
]
|
501 |
)
|
502 |
|
503 |
regen_story_btn.click(
|
504 |
+
story_gen_ui.disable_btns,
|
505 |
+
inputs=None,
|
506 |
+
outputs=[
|
507 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
508 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
509 |
+
action_btn1, action_btn2, action_btn3,
|
510 |
+
custom_action_txt,
|
511 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
512 |
+
]
|
513 |
+
).then(
|
514 |
story_gen_ui.update_story_gen,
|
515 |
inputs=[
|
516 |
cursors, cur_cursor,
|
|
|
536 |
outputs=[
|
537 |
action_btn1, action_btn2, action_btn3, progress_comp
|
538 |
]
|
539 |
+
).then(
|
540 |
+
story_gen_ui.enable_btns,
|
541 |
+
inputs=[story_image, story_audio],
|
542 |
+
outputs=[
|
543 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
544 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
545 |
+
action_btn1, action_btn2, action_btn3,
|
546 |
+
custom_action_txt,
|
547 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
548 |
+
]
|
549 |
)
|
550 |
|
551 |
#### Setups
|
|
|
612 |
)
|
613 |
|
614 |
image_gen_btn.click(
|
615 |
+
story_gen_ui.disable_btns,
|
616 |
+
inputs=None,
|
617 |
+
outputs=[
|
618 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
619 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
620 |
+
action_btn1, action_btn2, action_btn3,
|
621 |
+
custom_action_txt,
|
622 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
623 |
+
]
|
624 |
+
).then(
|
625 |
story_gen_ui.image_gen,
|
626 |
inputs=[
|
627 |
+
genre_dd, place_dd, mood_dd, title, story_content, cursors, cur_cursor
|
628 |
],
|
629 |
outputs=[
|
630 |
+
story_image, cursors, progress_comp,
|
631 |
+
]
|
632 |
+
).then(
|
633 |
+
story_gen_ui.enable_btns,
|
634 |
+
inputs=[story_image, story_audio],
|
635 |
+
outputs=[
|
636 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
637 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
638 |
+
action_btn1, action_btn2, action_btn3,
|
639 |
+
custom_action_txt,
|
640 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
641 |
]
|
642 |
)
|
643 |
|
644 |
audio_gen_btn.click(
|
645 |
+
story_gen_ui.disable_btns,
|
646 |
+
inputs=None,
|
647 |
+
outputs=[
|
648 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
649 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
650 |
+
action_btn1, action_btn2, action_btn3,
|
651 |
+
custom_action_txt,
|
652 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
653 |
+
]
|
654 |
+
).then(
|
655 |
story_gen_ui.audio_gen,
|
656 |
inputs=[
|
657 |
+
genre_dd, place_dd, mood_dd, title, story_content, cursors, cur_cursor
|
658 |
],
|
659 |
+
outputs=[story_audio, cursors, progress_comp]
|
660 |
+
).then(
|
661 |
+
story_gen_ui.enable_btns,
|
662 |
+
inputs=[story_image, story_audio],
|
663 |
+
outputs=[
|
664 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
665 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
666 |
+
action_btn1, action_btn2, action_btn3,
|
667 |
+
custom_action_txt,
|
668 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
669 |
+
]
|
670 |
)
|
671 |
|
672 |
img_audio_combine_btn.click(
|
673 |
+
story_gen_ui.disable_btns,
|
674 |
+
inputs=None,
|
675 |
+
outputs=[
|
676 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
677 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
678 |
+
action_btn1, action_btn2, action_btn3,
|
679 |
+
custom_action_txt,
|
680 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
681 |
+
]
|
682 |
+
).then(
|
683 |
story_gen_ui.video_gen,
|
684 |
inputs=[
|
685 |
story_image, story_audio, story_content, cursors, cur_cursor
|
|
|
687 |
outputs=[
|
688 |
story_image, story_audio, story_video, cursors, progress_comp
|
689 |
],
|
690 |
+
).then(
|
691 |
+
story_gen_ui.enable_btns,
|
692 |
+
inputs=[story_image, story_audio],
|
693 |
+
outputs=[
|
694 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
695 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
696 |
+
action_btn1, action_btn2, action_btn3,
|
697 |
+
custom_action_txt,
|
698 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
699 |
+
]
|
700 |
+
)
|
701 |
|
702 |
story_progress.input(
|
703 |
story_gen_ui.move_story_cursor,
|
|
|
714 |
)
|
715 |
|
716 |
action_btn1.click(
|
717 |
+
story_gen_ui.disable_btns,
|
718 |
inputs=None,
|
719 |
outputs=[
|
720 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
721 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
722 |
+
action_btn1, action_btn2, action_btn3,
|
723 |
+
custom_action_txt,
|
724 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
725 |
]
|
726 |
).then(
|
727 |
story_gen_ui.next_story_gen,
|
|
|
753 |
outputs=[
|
754 |
action_btn1, action_btn2, action_btn3, progress_comp
|
755 |
]
|
756 |
+
).then(
|
757 |
+
story_gen_ui.enable_btns,
|
758 |
+
inputs=[story_image, story_audio],
|
759 |
+
outputs=[
|
760 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
761 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
762 |
+
action_btn1, action_btn2, action_btn3,
|
763 |
+
custom_action_txt,
|
764 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
765 |
+
]
|
766 |
)
|
767 |
|
768 |
action_btn2.click(
|
769 |
+
story_gen_ui.disable_btns,
|
770 |
inputs=None,
|
771 |
outputs=[
|
772 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
773 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
774 |
+
action_btn1, action_btn2, action_btn3,
|
775 |
+
custom_action_txt,
|
776 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
777 |
]
|
778 |
).then(
|
779 |
story_gen_ui.next_story_gen,
|
|
|
805 |
outputs=[
|
806 |
action_btn1, action_btn2, action_btn3, progress_comp
|
807 |
]
|
808 |
+
).then(
|
809 |
+
story_gen_ui.enable_btns,
|
810 |
+
inputs=[story_image, story_audio],
|
811 |
+
outputs=[
|
812 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
813 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
814 |
+
action_btn1, action_btn2, action_btn3,
|
815 |
+
custom_action_txt,
|
816 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
817 |
+
]
|
818 |
)
|
819 |
|
820 |
action_btn3.click(
|
821 |
+
story_gen_ui.disable_btns,
|
822 |
inputs=None,
|
823 |
outputs=[
|
824 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
825 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
826 |
+
action_btn1, action_btn2, action_btn3,
|
827 |
+
custom_action_txt,
|
828 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
829 |
]
|
830 |
).then(
|
831 |
story_gen_ui.next_story_gen,
|
|
|
857 |
outputs=[
|
858 |
action_btn1, action_btn2, action_btn3, progress_comp
|
859 |
]
|
860 |
+
).then(
|
861 |
+
story_gen_ui.enable_btns,
|
862 |
+
inputs=[story_image, story_audio],
|
863 |
+
outputs=[
|
864 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
865 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
866 |
+
action_btn1, action_btn2, action_btn3,
|
867 |
+
custom_action_txt,
|
868 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
869 |
+
]
|
870 |
)
|
871 |
|
872 |
custom_action_txt.submit(
|
873 |
+
story_gen_ui.disable_btns,
|
874 |
inputs=None,
|
875 |
outputs=[
|
876 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
877 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
878 |
+
action_btn1, action_btn2, action_btn3,
|
879 |
+
custom_action_txt,
|
880 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
881 |
]
|
882 |
).then(
|
883 |
story_gen_ui.next_story_gen,
|
|
|
909 |
outputs=[
|
910 |
action_btn1, action_btn2, action_btn3, progress_comp
|
911 |
]
|
912 |
+
).then(
|
913 |
+
story_gen_ui.enable_btns,
|
914 |
+
inputs=[story_image, story_audio],
|
915 |
+
outputs=[
|
916 |
+
image_gen_btn, audio_gen_btn, img_audio_combine_btn,
|
917 |
+
regen_actions_btn, regen_story_btn, custom_prompt_txt,
|
918 |
+
action_btn1, action_btn2, action_btn3,
|
919 |
+
custom_action_txt,
|
920 |
+
restart_from_story_generation_btn, story_writing_done_btn
|
921 |
+
]
|
922 |
)
|
923 |
|
924 |
### Chatbot
|
|
|
977 |
outputs=[selected_side_char_image3]
|
978 |
)
|
979 |
|
980 |
+
demo.queue().launch(share=True)
|
interfaces/story_gen_ui.py
CHANGED
@@ -357,7 +357,7 @@ def video_gen(
|
|
357 |
|
358 |
|
359 |
def image_gen(
|
360 |
-
genre, place, mood, title, story_content, cursors, cur_cursor
|
361 |
):
|
362 |
# generate prompts for background image with PaLM
|
363 |
for _ in range(3):
|
@@ -382,20 +382,15 @@ def image_gen(
|
|
382 |
|
383 |
cursors[cur_cursor]["img"] = img_filename
|
384 |
|
385 |
-
video_gen_btn_state = gr.update(interactive=False)
|
386 |
-
if story_audio is not None:
|
387 |
-
video_gen_btn_state = gr.update(interactive=True)
|
388 |
-
|
389 |
return (
|
390 |
gr.update(visible=True, value=img_filename),
|
391 |
-
video_gen_btn_state,
|
392 |
cursors,
|
393 |
" "
|
394 |
)
|
395 |
|
396 |
|
397 |
def audio_gen(
|
398 |
-
genre, place, mood, title, story_content, cursors, cur_cursor
|
399 |
):
|
400 |
# generate prompt for background music with PaLM
|
401 |
for _ in range(3):
|
@@ -413,13 +408,8 @@ def audio_gen(
|
|
413 |
bgm_filename = bgm_maker.text2music(prompt, length=60)
|
414 |
cursors[cur_cursor]["audio"] = bgm_filename
|
415 |
|
416 |
-
video_gen_btn_state = gr.update(interactive=False)
|
417 |
-
if story_image is not None:
|
418 |
-
video_gen_btn_state = gr.update(interactive=True)
|
419 |
-
|
420 |
return (
|
421 |
gr.update(visible=True, value=bgm_filename),
|
422 |
-
video_gen_btn_state,
|
423 |
cursors,
|
424 |
" "
|
425 |
)
|
@@ -474,4 +464,50 @@ def move_story_cursor(moved_cursor, cursors):
|
|
474 |
|
475 |
def update_story_content(story_content, cursors, cur_cursor):
|
476 |
cursors[cur_cursor]["story"] = story_content
|
477 |
-
return cursors
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
|
358 |
|
359 |
def image_gen(
|
360 |
+
genre, place, mood, title, story_content, cursors, cur_cursor
|
361 |
):
|
362 |
# generate prompts for background image with PaLM
|
363 |
for _ in range(3):
|
|
|
382 |
|
383 |
cursors[cur_cursor]["img"] = img_filename
|
384 |
|
|
|
|
|
|
|
|
|
385 |
return (
|
386 |
gr.update(visible=True, value=img_filename),
|
|
|
387 |
cursors,
|
388 |
" "
|
389 |
)
|
390 |
|
391 |
|
392 |
def audio_gen(
|
393 |
+
genre, place, mood, title, story_content, cursors, cur_cursor
|
394 |
):
|
395 |
# generate prompt for background music with PaLM
|
396 |
for _ in range(3):
|
|
|
408 |
bgm_filename = bgm_maker.text2music(prompt, length=60)
|
409 |
cursors[cur_cursor]["audio"] = bgm_filename
|
410 |
|
|
|
|
|
|
|
|
|
411 |
return (
|
412 |
gr.update(visible=True, value=bgm_filename),
|
|
|
413 |
cursors,
|
414 |
" "
|
415 |
)
|
|
|
464 |
|
465 |
def update_story_content(story_content, cursors, cur_cursor):
|
466 |
cursors[cur_cursor]["story"] = story_content
|
467 |
+
return cursors
|
468 |
+
|
469 |
+
def disable_btns():
|
470 |
+
return (
|
471 |
+
gr.update(interactive=False), # image_gen_btn
|
472 |
+
gr.update(interactive=False), # audio_gen_btn
|
473 |
+
gr.update(interactive=False), # img_audio_combine_btn
|
474 |
+
|
475 |
+
gr.update(interactive=False), # regen_actions_btn
|
476 |
+
gr.update(interactive=False), # regen_story_btn
|
477 |
+
gr.update(interactive=False), # custom_prompt_txt
|
478 |
+
|
479 |
+
gr.update(interactive=False), # action_btn1
|
480 |
+
gr.update(interactive=False), # action_btn2
|
481 |
+
gr.update(interactive=False), # action_btn3
|
482 |
+
|
483 |
+
gr.update(interactive=False), # custom_action_txt
|
484 |
+
|
485 |
+
gr.update(interactive=False), # restart_from_story_generation_btn
|
486 |
+
gr.update(interactive=False), # story_writing_done_btn
|
487 |
+
)
|
488 |
+
|
489 |
+
def enable_btns(story_image, story_audio):
|
490 |
+
video_gen_btn_state = gr.update(interactive=False)
|
491 |
+
|
492 |
+
if story_image is not None and \
|
493 |
+
story_audio is not None:
|
494 |
+
video_gen_btn_state = gr.update(interactive=True)
|
495 |
+
|
496 |
+
return (
|
497 |
+
gr.update(interactive=True), # image_gen_btn
|
498 |
+
gr.update(interactive=True), # audio_gen_btn
|
499 |
+
video_gen_btn_state, # img_audio_combine_btn
|
500 |
+
|
501 |
+
gr.update(interactive=True), # regen_actions_btn
|
502 |
+
gr.update(interactive=True), # regen_story_btn
|
503 |
+
gr.update(interactive=True), # custom_prompt_txt
|
504 |
+
|
505 |
+
gr.update(interactive=True), # action_btn1
|
506 |
+
gr.update(interactive=True), # action_btn2
|
507 |
+
gr.update(interactive=True), # action_btn3
|
508 |
+
|
509 |
+
gr.update(interactive=True), # custom_action_txt
|
510 |
+
|
511 |
+
gr.update(interactive=True), # restart_from_story_generation_btn
|
512 |
+
gr.update(interactive=True), # story_writing_done_btn
|
513 |
+
)
|