-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathget_tryivona.py
44 lines (37 loc) · 1.28 KB
/
get_tryivona.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pyvona
import pygame
import subprocess
import utilities
from aptts import alarmpi_tts
class tryivona(alarmpi_tts):
def play(self, content, ramdrive='/mnt/ram/'):
if self.debug:
print "Trying Ivona."
rval = True
try:
#Connect to Ivona
v = pyvona.create_voice(self.sconfig['ivona_accesskey'],
self.sconfig['ivona_secretkey'])
#Settings for ivona
v.voice_name = self.sconfig['ivona_voice']
v.speech_rate = self.sconfig['ivona_speed']
#Get ogg file with speech
content = utilities.stripSymbols(content) # Removes symbols before sending to Ivona
v.fetch_voice(content, ramdrive + 'tempspeech.ogg')
# Play the oggs returned
pygame.mixer.init()
pygame.mixer.music.load(ramdrive + "tempspeech.ogg")
pygame.mixer.music.play()
while pygame.mixer.music.get_busy() == True:
continue
except pyvona.PyvonaException:
rval = False
except subprocess.CalledProcessError:
rval = False
# Cleanup any ogg files created in this directory.
print 'cleaning up now'
rmcmd = 'rm -f ' + ramdrive + '*' + self.sconfig['tail']
print subprocess.call (rmcmd, shell=True)
return rval