homeros_demo / main.py
papayaga's picture
init and basic architecture and logic in the Readme
ec2a0f3
raw
history blame
1.64 kB
import gradio as gr
from pprint import pprint
import uuid
import json
from loguru import logger
from dotenv import load_dotenv
load_dotenv()
from homeros import start_story, continue_story
def gen_unique_id():
return str(uuid.uuid4())
def do_homeros(user_input, story):
pprint(story)
if story["status"] == "not_started":
story["uuid"] = gen_unique_id()
return json.dumps(story["messages"]), story
demo = gr.Blocks()
with demo:
story = gr.State(value = {
"uuid" : "",
"status" : "not_started",
"world": "",
"hero": "",
"plot": "",
"ending": "",
"style": "",
"voice": "dylan",
"chunks" : [],
"messages": [],
"full_story_audio_ur": "",
"full_story_text": ""
})
pprint(story.value)
with gr.Row():
gr.Markdown('''
# HOMEROS
This demo is exploring the future of interactive storytelling.
It puts the user in charge and makes blurs the boundary between the reader and the author.
Hit "Tell me!" to get started.
When Homeros asks you something - hit record, answer with your voice and then hit "Tell me!" again.
''')
with gr.Row():
text_input = gr.Textbox()
with gr.Row():
go_btn = gr.Button(
"Tell me!",
)
with gr.Row():
story_chunk = gr.Textbox()
go_btn.click(
do_homeros,
inputs=[text_input, story],
outputs=[story_chunk, story]
)
demo.queue(
concurrency_count=5
)
demo.launch(
server_name="0.0.0.0",
ssl_verify=False,
show_api=False
)