added a dedicated sleep function

This commit is contained in:
deadvey
2026-04-01 18:27:39 +01:00
parent a912836c07
commit aff8a8dd43
4 changed files with 19 additions and 6 deletions

View File

@@ -30,6 +30,11 @@ c,f,h,i,l,m,o,q,t,u,v,w<br/>
**--help, -h**<br/>
Output's this help text and exits<br/>
## TODO
- Get the dictation to work with non-latin letters
- Get more languages supported
- Make the voice sound less robotic
## Languages
Current languages: English or Spanish, I plan to add more though.<br/>
The languages were downloaded from monkeytype.com

View File

@@ -27,7 +27,7 @@ def words(config, engine):
engine.say(word)
engine.runAndWait()
# Break between words as determined by the wpm
time.sleep(1/(config['wpm']/60))
maths.sleep(config['wpm'])
# TIMED #
def timed(config, engine):
@@ -46,8 +46,7 @@ def timed(config, engine):
print(f'{word} ')
engine.runAndWait()
# Break between words as determined by the wpm
time.sleep(1/(config['wpm']/60))
maths.sleep(config['wpm'])
# check if too much time has elapsed for mode: time
now = time.time()
# Break condition
@@ -73,7 +72,7 @@ def quote(config, engine):
engine.say(word)
engine.runAndWait()
# Break between words as determined by the wpm
time.sleep(1/(config['wpm']/60))
maths.sleep(config['wpm'])
# FILE #
def file(config, engine):
@@ -93,4 +92,4 @@ def file(config, engine):
engine.say(word)
engine.runAndWait()
# Break between words as determined by the wpm
time.sleep(1/(config['wpm']/60))
maths.sleep(config['wpm'])

View File

@@ -1,4 +1,11 @@
import random
import time
# Random number generator that's biased towards 0
def biased_random(max_value, strength=3):
return round((random.random() ** strength) * max_value)
def sleep(wpm):
sleep_time = (1/(wpm/60))-1
if sleep_time > 0.0:
time.sleep(sleep_time)

View File

@@ -105,5 +105,7 @@
{ "quote":"A computer is like air conditioning - it becomes useless when you open Windows", "author":"Linus Torvalds"},
{ "quote":"Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program.", "author": "Linus Torvalds"},
{ "quote":"An idiot admires complexity, a genius admires simplicity.", "author":"Terry A. Davis"},
{ "quote":"It is not the well-fed long-haired man I fear, but the pale and the hungry looking.", "author":"Gauis Julius Caesar"}
{ "quote":"It is not the well-fed long-haired man I fear, but the pale and the hungry looking.", "author":"Gauis Julius Caesar"},
{ "quote":"No, Luke, I am your father", "author":"Anakin Skywalker"},
{ "quote":"Do you wish me a good morning, or mean that it is a good morning whether I want it or not; or that you feel good this morning; or that it is a morning to be good on?", "author":"J.R.R. Tolkien (Gandalf)"}
]