Spaces:
Runtime error
Runtime error
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) | |