audiologic.py
2.43 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#synthDrivers/audiologic.py
#A part of NonVisual Desktop Access (NVDA)
#This file is covered by the GNU General Public License.
#See the file COPYING for more details.
#Copyright (C) 2008-2010 Gianluca Casalino <gianluca@spazioausili.net>, James Teh <jamie@jantrid.net>
from collections import OrderedDict
import _audiologic
from synthDriverHandler import SynthDriver, VoiceInfo
import _winreg
class SynthDriver(SynthDriver):
supportedSettings=(SynthDriver.RateSetting(),SynthDriver.PitchSetting(minStep=5),SynthDriver.InflectionSetting(minStep=10),SynthDriver.VolumeSetting(minStep=2))
description="Audiologic Tts3"
name="audiologic"
@classmethod
def check(cls):
try:
r=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,"SOFTWARE\Audiologic\Sintesi Audiologic")
r.Close()
return True
except:
return False
def __init__(self):
_audiologic.TtsOpen()
def terminate(self):
_audiologic.TtsClose()
def speakText(self,text,index=None):
if isinstance(index,int) and index>=0:
text="[:BMK=%d]%s"%(index,text)
_audiologic.TtsSpeak(text)
def _get_lastIndex(self):
return _audiologic.LastIndex
def cancel(self):
_audiologic.TtsStop()
def _getAvailableVoices(self):
return OrderedDict((
("", VoiceInfo("", "Tts3", language="it")),
))
def _get_voice(self):
return ""
def _set_voice(self, voice):
pass
def _get_rate(self):
return self._paramToPercent(_audiologic.TtsGetProsody('Speed') ,_audiologic.minRate, _audiologic.maxRate)
def _set_rate(self,value):
_audiologic.TtsSetParam(_audiologic.ttsRate, self._percentToParam(value, _audiologic.minRate, _audiologic.maxRate), 0)
def _get_pitch(self):
return self._paramToPercent(_audiologic.TtsGetProsody('Pitch'),_audiologic.minPitch, _audiologic.maxPitch)
def _set_pitch(self,value):
_audiologic.TtsSetParam(_audiologic.ttsPitch,self._percentToParam(value, _audiologic.minPitch, _audiologic.maxPitch), 0)
def _get_volume(self):
return self._paramToPercent(_audiologic.TtsGetProsody('Vol'),_audiologic.minVol, _audiologic.maxVol)
def _set_volume(self,value):
_audiologic.TtsSetParam(_audiologic.ttsVol,self._percentToParam(value, _audiologic.minVol, _audiologic.maxVol), 0)
def _get_inflection(self):
return _audiologic.TtsGetProsody('Expression') *10
def _set_inflection(self,value):
_audiologic.TtsSetParam(_audiologic.ttsExpression,int(value/10), 0)
def pause(self,switch):
if switch:
_audiologic.TtsPause()
else:
_audiologic.TtsRestart()