From aff8a8dd4396b570b2126cbfb350168b5b39c593 Mon Sep 17 00:00:00 2001 From: deadvey Date: Wed, 1 Apr 2026 18:27:39 +0100 Subject: [PATCH] added a dedicated sleep function --- README.md | 5 +++++ dictate.py | 9 ++++----- maths.py | 7 +++++++ quotes/en.json | 4 +++- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d67c161..8fd7f7c 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,11 @@ c,f,h,i,l,m,o,q,t,u,v,w
**--help, -h**
Output's this help text and exits
+## 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.
The languages were downloaded from monkeytype.com diff --git a/dictate.py b/dictate.py index 0bed272..1969226 100644 --- a/dictate.py +++ b/dictate.py @@ -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']) diff --git a/maths.py b/maths.py index 3035ca6..939d24f 100644 --- a/maths.py +++ b/maths.py @@ -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) + diff --git a/quotes/en.json b/quotes/en.json index 050dad5..931faed 100644 --- a/quotes/en.json +++ b/quotes/en.json @@ -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)"} ]