Spaces:
Runtime error
Runtime error
Unavailable1
commited on
Commit
•
641d9dc
1
Parent(s):
6fc16ce
Update app.py
Browse files
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
|
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 |
-
|
34 |
-
print("Time Taken (seconds):", time_taken)
|
35 |
-
print("Reading Speed (WPM):", wpm)
|
36 |
|
37 |
-
#
|
38 |
-
text
|
39 |
-
|
40 |
-
""
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
|
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()
|