File size: 1,633 Bytes
641d9dc
62ed5a5
9552297
 
 
 
 
641d9dc
9552297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
641d9dc
9552297
641d9dc
 
 
 
9552297
3f48ec3
 
 
d587d14
641d9dc
3f48ec3
 
 
 
4a571df
3f48ec3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import gradio as gr
import time
from transformers import pipeline

# Load the speed reading model from Hugging Face Spaces
speed_reading = pipeline("text-classification", model="sberbank-ai/rugpt3small_based_on_gpt2")

def perform_speed_reading(text):
    # Split the text into individual sentences
    sentences = text.split(".")
    
    # Initialize variables to store results
    words_read = 0
    time_taken = 0
    
    # Loop through each sentence and read it using speed reading model
    for sentence in sentences:
        # Measure time taken to read each sentence
        start_time = time.time()
        
        # Read the sentence using speed reading model
        speed_reading(sentence)
        
        # Calculate time taken to read the sentence
        end_time = time.time()
        time_taken += end_time - start_time
        
        # Count the number of words read
        words_read += len(sentence.split())
    
    # Calculate reading speed in words per minute (WPM)
    wpm = (words_read / time_taken) * 60
    
    return words_read, time_taken, wpm

# Interface
def speed_reading_interface(text):
    words_read, time_taken, wpm = perform_speed_reading(text)
    return f"Words Read: {words_read}, Time Taken (seconds): {time_taken}, Reading Speed (WPM): {wpm}"

inputs = gr.inputs.Textbox(placeholder="Enter text here")
output = gr.outputs.Textbox(label="Results")

gr.Interface()
    fn=speed_reading_interface,
    inputs=inputs,
    outputs=output,
    title="Speed Reading Test",
    description="Enter the text you want to speed read, and see how many words you can read per minute.",

.launch()