File size: 983 Bytes
40fb01d
b748808
40fb01d
b748808
 
 
60b66fc
 
 
 
 
 
 
 
 
 
b748808
60b66fc
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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()