Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/tts.py
blob: d94fbf1ee77aadc29424dd1a920f2f71cd88bf3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class TTS():
	def __init__(self):
		try:
			import pyttsx3
			self._available = True
		except:
			self._available = False

	@property
	def available(self):
		return self._available
	@property
	def is_available(self):
		return self._available

	@property
	def volume(self):
		return self.engine.getProperty('volume')

	@volume.setter
	def volume(self, percentage):
		self.engine.setProperty('volume', percentage/100)
		return self.volume
	

	def speak(self, phrase):
		if self.available:
			self.engine.say("I will speak this text")
			engine.runAndWait()

	def __enter__(self):
		self.engine = pyttsx3.init()
		return self

	def __exit__(self, *args, **kwargs):
		self.engine.stop()