Skip to content

Commit

Permalink
A very rough, experimental demonstration of what can be done with SSML.
Browse files Browse the repository at this point in the history
Implemented a ssml  translator inherriting from speech.  Overwritten subscripts to produce a pitch decrement and roots to include a pause.

Added a test_ssml script.  This prints the ssml translation but the output can be piped to espeak with 
./test_ssml | espeak -m
  • Loading branch information
ajirving committed Jul 29, 2012
1 parent cbca5e0 commit 1dc02a9
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
38 changes: 38 additions & 0 deletions latex_access/ssml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ssml.py
# A part of the latex-access project at http://latex-access.sourceforge.net/
# Author: Alastair Irving <[email protected]>
# Copyright (C) 2011 Alastair Irving/latex-access Contributors
#
# This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation;
# either version 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this program; if not, visit <http://www.gnu.org/licenses>
#
'''Experimental Module to provide speech output in SSML for latex_access.'''


import speech
from latex_access import get_arg

sb='<break strength="strong">'

class ssml(speech.speech):
def __init__(self):
speech.speech.__init__(self)
self.table["_"]=('<prosody pitch="-15%">','</prosody>')


def sqrt(self,input,start):
'''Translates squareroots into speech.
returns touple.'''
arg=get_arg(input,start)
if arg[0].isdigit() or len(arg[0])==1:
translation=" root "+arg[0]
else:
translation=" begin root "+sb+self.translate(arg[0])+" end root "+sb
return (translation,arg[1])
16 changes: 16 additions & 0 deletions test_ssml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/python
'''Script to translate lines of laTeX from stdin to in stdout.'''


import sys
import latex_access.ssml as ssml


s=ssml.ssml()


while True:
input = sys.stdin.readline()
output=s.translate(input)
print output
sys.stdout.flush()

0 comments on commit 1dc02a9

Please sign in to comment.