File size: 1,550 Bytes
62ed5a5
9552297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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 speed_reading_test(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
    
    print("Words Read:", words_read)
    print("Time Taken (seconds):", time_taken)
    print("Reading Speed (WPM):", wpm)

# Example text for testing
text = """
This is an example speed reading test. It is designed to measure your reading speed using a machine learning model. You will be presented with a series of sentences. Your task is to read each sentence as quickly as possible while maintaining comprehension. At the end of the test, your reading speed will be calculated in words per minute.
"""

speed_reading_test(text)