MCPcopy Index your code
hub / github.com/geekcomputers/Python / init_tts_engine

Function init_tts_engine

JARVIS/speech.py:32–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30
31
32def init_tts_engine():
33 if win32com_client is not None:
34 try:
35 voice = win32com_client.Dispatch("SAPI.SpVoice")
36 voices = voice.GetVoices()
37 if voices.Count:
38 voice.Voice = voices.Item(0)
39 return voice
40 except Exception as exc:
41 print(f"SAPI voice disabled: {exc}")
42 if pyttsx3 is None:
43 return None
44 try:
45 engine = pyttsx3.init()
46 voices = engine.getProperty("voices")
47 if voices:
48 engine.setProperty("voice", voices[0].id)
49 engine.setProperty("rate", 165)
50 return engine
51 except Exception as exc:
52 print(f"TTS engine disabled: {exc}")
53 return None
54
55
56def set_tts_engine(engine):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected