removed duplicating words when using .split(' '), which produces empty None strings, used filter(None, ...) to remove these empty strings

This commit is contained in:
deadvey
2026-04-02 01:18:25 +01:00
parent aff8a8dd43
commit 31e7eab069

View File

@@ -66,7 +66,7 @@ def quote(config, engine):
x = random.randint(0, len(quotes)-1)
quote = quotes[x]
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
for word in dictation:
engine.say(word)
@@ -88,7 +88,7 @@ def file(config, engine):
print(line)
# Dictation loop
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.runAndWait()
# Break between words as determined by the wpm