Removed the old get_dictation file and updated the text outputing of the dictations
This commit is contained in:
11
dictate.py
11
dictate.py
@@ -13,10 +13,12 @@ def words(config):
|
||||
dump = json.load(file)
|
||||
words_list = dump['words']
|
||||
dictation = []
|
||||
if not 'mode_modifier' in config:
|
||||
config['mode_modifier'] = 20
|
||||
for i in range(0, config['mode_modifier']):
|
||||
word = words_list[maths.biased_random(len(words_list)-1)]
|
||||
dictation.append(word)
|
||||
print(word,end=' ')
|
||||
print(word)
|
||||
for word in dictation:
|
||||
engine.say(word)
|
||||
engine.runAndWait()
|
||||
@@ -28,6 +30,8 @@ def timed(config):
|
||||
with open(f'languages/{config['language']}.json', 'r') as file:
|
||||
dump = json.load(file)
|
||||
words_list = dump['words']
|
||||
if not 'mode_modifier' in config:
|
||||
config['mode_modifier'] = 30
|
||||
# For keeping track of time
|
||||
start = time.time()
|
||||
while 1==1:
|
||||
@@ -63,9 +67,12 @@ def file(config):
|
||||
engine = pyttsx3.init()
|
||||
with open(f'{config['mode_modifier']}', 'r') as file:
|
||||
lines = file.readlines()
|
||||
# Text output
|
||||
for line in lines:
|
||||
print(line)
|
||||
# Dictation loop
|
||||
for line in lines:
|
||||
for word in line.split(' '):
|
||||
print(word,end=' ')
|
||||
engine.say(word)
|
||||
engine.runAndWait()
|
||||
time.sleep(1/(config['wpm']/60))
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
import json
|
||||
import maths
|
||||
import random
|
||||
|
||||
def words(config):
|
||||
dictation = []
|
||||
words_list = []
|
||||
with open(f'languages/{config['language']}.json', 'r') as file:
|
||||
dump = json.load(file)
|
||||
words_list = dump['words']
|
||||
|
||||
for i in range(0,config['mode_modifier']):
|
||||
x = maths.biased_random(len(words_list)-1)
|
||||
dictation.append(words_list[x])
|
||||
return dictation
|
||||
|
||||
def time(config):
|
||||
dictation = []
|
||||
words_list = []
|
||||
with open(f'languages/{config['language']}.json', 'r') as file:
|
||||
dump = json.load(file)
|
||||
words_list = dump['words']
|
||||
|
||||
# TODO: Really, these should be generated on demand
|
||||
for i in range(0,config['mode_modifier']*3):
|
||||
x = maths.biased_random(len(words_list)-1)
|
||||
dictation.append(words_list[x])
|
||||
return dictation
|
||||
|
||||
def quote(config):
|
||||
dictation = []
|
||||
with open(f'quotes/{config['language']}.json', 'r') as file:
|
||||
quotes = json.load(file)
|
||||
print(quotes)
|
||||
x = random.randint(0,len(quotes)-1)
|
||||
print(quotes[x])
|
||||
|
||||
return dictation
|
||||
Reference in New Issue
Block a user