MCPcopy Create free account
hub / github.com/ActiveState/code / selectVoice

Method selectVoice

recipes/Python/167487_Windows_SAPI4/recipe-167487.py:40–86  ·  view source on GitHub ↗
(self, voice_name='')

Source from the content-addressed store, hash-verified

38 return None
39
40 def selectVoice(self, voice_name=''):
41 #select voice
42 voice_index = 0
43 voice_no = 0
44 found = 0
45 for voice_compare in self.voice_list:
46 voice_no = voice_no + 1
47 if voice_compare == voice_name:
48 found = 1
49 break
50 if found == 0:
51 voice_no = 1
52 self.directss.AudioReset()
53
54 try:
55 self.directss.Select(voice_no)
56 self.sapi_compliant = 1
57 except:
58 self.sapi_compliant = 0
59 self.directss.Speak(' ') #don't understand why we need this here but voice doesn't change otherwise
60 self.voice_no = voice_no
61 self.voice_index = voice_no - 1
62 self.voice_name = self.directss.ModeName(voice_no)
63 #print 'Selected voice: ' + self.voice_name
64
65 self.MinSpeed = self.directss.MinSpeed
66 self.MaxSpeed = self.directss.MaxSpeed
67 self.Speed = self.directss.Speed
68 #print 'Speed: from ' + str(self.MinSpeed) + ' to ' + str(self.MaxSpeed) + ' - current ' + str(self.Speed)
69
70 self.MinPitch = self.directss.MinPitch
71 self.MaxPitch = self.directss.MaxPitch
72 self.Pitch = self.directss.Pitch
73 #print 'Pitch: from ' + str(self.MinPitch) + ' to ' + str(self.MaxPitch) + ' - current ' + str(self.Pitch)
74
75 self.MinVolumeLeft = self.directss.MinVolumeLeft
76 self.MaxVolumeLeft = self.directss.MaxVolumeLeft
77 self.VolumeLeft = self.directss.VolumeLeft
78 #print 'VolumeLeft: from ' + str(self.MinVolumeLeft) + ' to ' + str(self.MaxVolumeLeft) + ' - current ' + str(self.VolumeLeft)
79
80 self.MinVolumeRight = self.directss.MinVolumeRight
81 self.MaxVolumeRight = self.directss.MaxVolumeRight
82 self.VolumeRight = self.directss.VolumeRight
83 #print 'VolumeRight: from ' + str(self.MinVolumeRight) + ' to ' + str(self.MaxVolumeRight) + ' - current ' + str(self.VolumeRight)
84 #print
85
86 return voice_no
87
88 def getVoiceList(self):
89 #fill list of avaliable voices

Callers 2

__init__Method · 0.95
setVoiceMethod · 0.80

Calls 1

SelectMethod · 0.80

Tested by

no test coverage detected