I was wondering if it was possible to detect how long a period takes in pyttsx3, I'm trying to build a live subtitler, that gets the script and then basically provides the amount of time each word lasts for. (english isnt first language, so script might not have right logic.)
def count_syllables(self, word: str):
vowels = "aeiouy"
count = 0
prev_char_was_vowel = False
for char in word.lower():
if char in vowels:
if not prev_char_was_vowel:
count += 1
prev_char_was_vowel = True
else:
prev_char_was_vowel = False
if len(word) == 1:
count = 1
return count
also new to stackoverflow, so sorry if there are any errors.