Unavailable1 commited on
Commit
641d9dc
1 Parent(s): 6fc16ce

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -1,10 +1,11 @@
 
1
  import time
2
  from transformers import pipeline
3
 
4
  # Load the speed reading model from Hugging Face Spaces
5
  speed_reading = pipeline("text-classification", model="sberbank-ai/rugpt3small_based_on_gpt2")
6
 
7
- def speed_reading_test(text):
8
  # Split the text into individual sentences
9
  sentences = text.split(".")
10
 
@@ -30,13 +31,15 @@ def speed_reading_test(text):
30
  # Calculate reading speed in words per minute (WPM)
31
  wpm = (words_read / time_taken) * 60
32
 
33
- print("Words Read:", words_read)
34
- print("Time Taken (seconds):", time_taken)
35
- print("Reading Speed (WPM):", wpm)
36
 
37
- # Example text for testing
38
- text = """
39
- 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.
40
- """
41
 
42
- speed_reading_test(text)
 
 
 
 
 
1
+ import gradio as gr
2
  import time
3
  from transformers import pipeline
4
 
5
  # Load the speed reading model from Hugging Face Spaces
6
  speed_reading = pipeline("text-classification", model="sberbank-ai/rugpt3small_based_on_gpt2")
7
 
8
+ def perform_speed_reading(text):
9
  # Split the text into individual sentences
10
  sentences = text.split(".")
11
 
 
31
  # Calculate reading speed in words per minute (WPM)
32
  wpm = (words_read / time_taken) * 60
33
 
34
+ return words_read, time_taken, wpm
 
 
35
 
36
+ # Interface
37
+ def speed_reading_interface(text):
38
+ words_read, time_taken, wpm = perform_speed_reading(text)
39
+ return f"Words Read: {words_read}, Time Taken (seconds): {time_taken}, Reading Speed (WPM): {wpm}"
40
 
41
+ gr.Interface(
42
+ fn=speed_reading_interface,
43
+ inputs=gr.inputs.Textbox(lines=10, label="Enter text here"),
44
+ outputs="text"
45
+ ).launch()