Ireneo's picture
Update app.py
60b66fc
raw
history blame
983 Bytes
import gradio as gr
import time
# Load the model
model = gr.Interface.load("models/roneneldan/TinyStories-Instruct-33M")
# Simulate the typing effect
def simulate_typing(input_text):
typing_speed = 0.05 # Adjust the speed of typing
generated_text = model.predict(input_text)
for char in generated_text:
time.sleep(typing_speed)
# Update the text display area in the Android app with each character
# You'll need to implement this part in your Android app using appropriate methods.
# For example, you can update the TextView in Android with the new character.
return generated_text
# Launch the interface
gr.Interface(fn=simulate_typing, inputs=gr.inputs.Textbox(label="Input Text", placeholder="Enter your story here..."),
outputs=gr.outputs.Textbox(label="Generated Story"), title="Tiny Stories Generator",
description="This model generates creative stories based on the input text provided.").launch()