removed duplicating words when using .split(' '), which produces empty None strings, used filter(None, ...) to remove these empty strings
This commit is contained in:
@@ -66,7 +66,7 @@ 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)
|
||||||
@@ -88,7 +88,7 @@ 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
|
||||||
|
|||||||
Reference in New Issue
Block a user