import bgm import gradio as gr def show_textbox(radio_state): if(radio_state == "User Input"): return [gr.Textbox.update(visible=False), gr.Textbox.update(visible=False), gr.Textbox.update(visible=True)] elif(radio_state == "ChatGPT"): return [gr.Textbox.update(visible=True), gr.Textbox.update(visible=True), gr.Textbox.update(visible=False)] else: return [gr.Textbox.update(visible=False) for _ in range(2)] def generate_video(text_in): ambient_music = bgm.text2audio(text=text_in, duration=20, guidance_scale=5, random_seed=24, n_candidates=3) print(ambient_music) return ambient_music def download_video(v): pass with gr.Blocks() as demo: gr.Markdown("Generate a narrated horror story video from a text prompt or your own story.") with gr.Row(): with gr.Column(): radio_input = gr.Radio(["ChatGPT", "User Input"], type="value", label="Input method") auth_input = gr.Textbox(label="Auth Key", max_lines=1, visible=False, interactive=True) prompt_input = gr.Textbox(label="Prompt", lines=5, visible=False, interactive=True) text_input = gr.Textbox(label="Your Story", lines=5, visible=False, interactive=True) text_lst = [auth_input, prompt_input, text_input] radio_input.change(show_textbox, radio_input, text_lst) generate_button = gr.Button("Generate Video") with gr.Column(): video_out = gr.Video(label="Output", interactive=False) download_button = gr.Button("Download") generate_button.click(generate_video, inputs=[text_input], outputs=[video_out]) download_button.click(download_video, inputs=video_out) demo.launch(debug=True, enable_queue=True)