Compare commits
4 Commits
9923bda2a1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31e7eab069 | ||
|
|
aff8a8dd43 | ||
|
|
a912836c07 | ||
|
|
302d7ea2e4 |
@@ -4,7 +4,7 @@ You can configure the playback speed, language and mode (timed, words, quote or
|
|||||||
|
|
||||||
## Command line options
|
## Command line options
|
||||||
All these options overide configuration in config.json<br/>
|
All these options overide configuration in config.json<br/>
|
||||||
c,f,h,i,l,m,o,q,t,u,v,w
|
c,f,h,i,l,m,o,q,t,u,v,w<br/>
|
||||||
**--wpm, -w <int>**<br/>
|
**--wpm, -w <int>**<br/>
|
||||||
set the rate of dictation, defaults to 50, note: this is not exact as it measures the time between words in order to avoid a very short gap after a long word.<br/>
|
set the rate of dictation, defaults to 50, note: this is not exact as it measures the time between words in order to avoid a very short gap after a long word.<br/>
|
||||||
**--mode, -m <mode>**<br/>
|
**--mode, -m <mode>**<br/>
|
||||||
@@ -30,6 +30,11 @@ c,f,h,i,l,m,o,q,t,u,v,w
|
|||||||
**--help, -h**<br/>
|
**--help, -h**<br/>
|
||||||
Output's this help text and exits<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
|
## Languages
|
||||||
Current languages: English or Spanish, I plan to add more though.<br/>
|
Current languages: English or Spanish, I plan to add more though.<br/>
|
||||||
The languages were downloaded from monkeytype.com
|
The languages were downloaded from monkeytype.com
|
||||||
|
|||||||
31
args.py
31
args.py
@@ -35,6 +35,37 @@ def handle_arguments(arguments, config, engine):
|
|||||||
for voice in voices:
|
for voice in voices:
|
||||||
print(voice)
|
print(voice)
|
||||||
exit()
|
exit()
|
||||||
|
case '--help'|'h':
|
||||||
|
print('''Command line options
|
||||||
|
All these options overide configuration in config.json
|
||||||
|
c,f,h,i,l,m,o,q,t,u,v,w
|
||||||
|
--wpm, -w <int>
|
||||||
|
set the rate of dictation, defaults to 50, note: this is not exact as it measures the time between words in order to avoid a very short gap after a long word.
|
||||||
|
--mode, -m <mode>
|
||||||
|
Sets a mode, one of 'timed', 'words','quote' or 'file' followed by an optional modifier representing either the time (in seconds) or the number of words, or the quote ID, or the file name.
|
||||||
|
--filename, -f <filename>
|
||||||
|
Passes a filename as parameter for the file mode
|
||||||
|
--words, -o <number of words>
|
||||||
|
Number of words for words mode
|
||||||
|
--time, -t <time>
|
||||||
|
Time in seconds for timed mode
|
||||||
|
--quote, -q <time>
|
||||||
|
Specify a quote ID for quotes mode, see all quotes in your selected language with -u
|
||||||
|
--language, -l <language>
|
||||||
|
Selects a language, defaults to english, must be a listed language in -i
|
||||||
|
--voice, -v <voice id>
|
||||||
|
Selects a voice to use, defaults to gwm/en in config.json
|
||||||
|
--list-voices, -c
|
||||||
|
Lists all the available voices you can use, also see [voices.txt](voices.txt)
|
||||||
|
--list-quotes, -u
|
||||||
|
Lists the available quotes and exits
|
||||||
|
--list-languages, -i
|
||||||
|
Lists the installed languages and exits
|
||||||
|
--help, -h
|
||||||
|
Output's this help text and exits
|
||||||
|
''')
|
||||||
|
exit()
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
continue
|
continue
|
||||||
return config
|
return config
|
||||||
|
|||||||
13
dictate.py
13
dictate.py
@@ -27,7 +27,7 @@ def words(config, engine):
|
|||||||
engine.say(word)
|
engine.say(word)
|
||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
# Break between words as determined by the wpm
|
# Break between words as determined by the wpm
|
||||||
time.sleep(1/(config['wpm']/60))
|
maths.sleep(config['wpm'])
|
||||||
|
|
||||||
# TIMED #
|
# TIMED #
|
||||||
def timed(config, engine):
|
def timed(config, engine):
|
||||||
@@ -46,8 +46,7 @@ def timed(config, engine):
|
|||||||
print(f'{word} ')
|
print(f'{word} ')
|
||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
# Break between words as determined by the wpm
|
# 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
|
# check if too much time has elapsed for mode: time
|
||||||
now = time.time()
|
now = time.time()
|
||||||
# Break condition
|
# Break condition
|
||||||
@@ -67,13 +66,13 @@ def quote(config, engine):
|
|||||||
x = random.randint(0, len(quotes)-1)
|
x = random.randint(0, len(quotes)-1)
|
||||||
quote = quotes[x]
|
quote = quotes[x]
|
||||||
print(f'{quote['quote']}\n\t\t\t - {quote['author']}')
|
print(f'{quote['quote']}\n\t\t\t - {quote['author']}')
|
||||||
dictation = quote['quote'].split(' ')
|
dictation = filter(None, quote['quote'].split(' ')) # turn the string into a list of words, the filter function removes empty strings
|
||||||
# Dictate the quote
|
# Dictate the quote
|
||||||
for word in dictation:
|
for word in dictation:
|
||||||
engine.say(word)
|
engine.say(word)
|
||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
# Break between words as determined by the wpm
|
# Break between words as determined by the wpm
|
||||||
time.sleep(1/(config['wpm']/60))
|
maths.sleep(config['wpm'])
|
||||||
|
|
||||||
# FILE #
|
# FILE #
|
||||||
def file(config, engine):
|
def file(config, engine):
|
||||||
@@ -89,8 +88,8 @@ def file(config, engine):
|
|||||||
print(line)
|
print(line)
|
||||||
# Dictation loop
|
# Dictation loop
|
||||||
for line in lines:
|
for line in lines:
|
||||||
for word in line.split(' '):
|
for word in filter(None, line.split(' ')): # the filter function removes empty strings
|
||||||
engine.say(word)
|
engine.say(word)
|
||||||
engine.runAndWait()
|
engine.runAndWait()
|
||||||
# Break between words as determined by the wpm
|
# Break between words as determined by the wpm
|
||||||
time.sleep(1/(config['wpm']/60))
|
maths.sleep(config['wpm'])
|
||||||
|
|||||||
7
maths.py
7
maths.py
@@ -1,4 +1,11 @@
|
|||||||
import random
|
import random
|
||||||
|
import time
|
||||||
|
|
||||||
# Random number generator that's biased towards 0
|
# Random number generator that's biased towards 0
|
||||||
def biased_random(max_value, strength=3):
|
def biased_random(max_value, strength=3):
|
||||||
return round((random.random() ** strength) * max_value)
|
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)
|
||||||
|
|
||||||
|
|||||||
@@ -105,5 +105,7 @@
|
|||||||
{ "quote":"A computer is like air conditioning - it becomes useless when you open Windows", "author":"Linus Torvalds"},
|
{ "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":"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":"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)"}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user