Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Speak.activity/voice.py
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-02-21 12:49:31 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-02-21 12:49:31 (GMT)
commitf0b74984b013ddf730b7b947318d7dd5826346e4 (patch)
treef4ee02bbbf62d4183d84237f808a213f3ef7344b /Speak.activity/voice.py
parent5d52643ce4d2341200e390b910f89d45ca98e822 (diff)
Use espeak command when gst-plugins-espeak is not installed(Joshua Minor)
Diffstat (limited to 'Speak.activity/voice.py')
-rw-r--r--Speak.activity/voice.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/Speak.activity/voice.py b/Speak.activity/voice.py
index 9727fb0..256bbf0 100644
--- a/Speak.activity/voice.py
+++ b/Speak.activity/voice.py
@@ -22,6 +22,7 @@
# along with Speak.activity. If not, see <http://www.gnu.org/licenses/>.
+import subprocess
import pygst
pygst.require("0.10")
import gst
@@ -84,16 +85,29 @@ class Voice:
def allVoices():
if len(_allVoices) == 0:
- for i in gst.element_factory_make('espeak').props.voices:
- name, language = i.split(':')
- if name in ('en-rhotic','english_rp','english_wmids'):
- # these voices don't produce sound
- continue
- voice = Voice(language, name)
- _allVoices[voice.friendlyname] = voice
-
+ try:
+ for i in gst.element_factory_make('espeak').props.voices:
+ name, language = i.split(':')
+ if name in ('en-rhotic','english_rp','english_wmids'):
+ # these voices don't produce sound
+ continue
+ voice = Voice(language, name)
+ _allVoices[voice.friendlyname] = voice
+ except:
+ result = subprocess.Popen(["espeak", "--voices"], stdout=subprocess.PIPE).communicate()[0]
+ for line in result.split('\n'):
+ m = re.match(r'\s*\d+\s+([\w-]+)\s+([MF])\s+([\w_-]+)\s+(.+)', line)
+ if m:
+ language, gender, name, stuff = m.groups()
+ if stuff.startswith('mb/') or name in ('en-rhotic','english_rp','english_wmids'):
+ # these voices don't produce sound
+ continue
+ voice = Voice(language, name)
+ _allVoices[voice.friendlyname] = voice
return _allVoices
+
+
def defaultVoice():
"""Try to figure out the default voice, from the current locale ($LANG).
Fall back to espeak's voice called Default."""