I followed a tutorial on Youtube on how to do TextToSpeech with python, and I am getting the following error
import re
import wave
import pyaudio
import _thread
import time
class TextToSpeech:
CHUNK = 1024
def __init__(self, words_pron_dict:str = 'cmudict-0.7b.txt'):
    self._l = {}//Error right here ^
    self._load_words(words_pron_dict)
def _load_words(self, words_pron_dict:str):
    with open(words_pron_dict, 'r') as file:
        for line in file:
            if not line.startswith(';;;'):
                key, val = line.split('  ',2)
                self._l[key] = re.findall(r"[A-Z]+",val)
def get_pronunciation(self, str_input):
    list_pron = []
    for word in re.findall(r"[\w']+",str_input.upper()):
        if word in self._l:
            list_pron += self._l[word]
    print(list_pron)
    delay=0
    for pron in list_pron:
        _thread.start_new_thread( TextToSpeech._play_audio, (pron,delay,))
        delay += 0.145
def _play_audio(sound, delay):
    try:
        time.sleep(delay)
        wf = wave.open("sounds/"+sound+".wav", 'rb')
        p = pyaudio.PyAudio()
        stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),
                        channels=wf.getnchannels(),
                        rate=wf.getframerate(),
                        output=True)
        data = wf.readframes(TextToSpeech.CHUNK)
        while data:
            stream.write(data)
            data = wf.readframes(TextToSpeech.CHUNK)
        stream.stop_stream()
        stream.close()
        p.terminate()
        return
    except:
        pass
if __name__ == '__main__':
tts = TextToSpeech()
while True:
    tts.get_pronunciation(input('Enter a word or phrase: '))
The error is "Invalid Sytanx" right where the colon is right before "str" at the top. I'm not sure what I am doing wrong. I am using IDLE for the editor, this script requires pyaudio, which I have installed, and it also requires the document "cmudict-0.7b.text" which I also have.
I've tried copying the name of the file directly to the code, adding parenthesis changing the ' to a " where the txt file name is, to no prevail. I would appreciate it if someone could help me on this and give me some insight on what I'm doing wrong.
I'm using Python 2.7.
Thanks.
