From 1dc02a927c133ba5121a6f969b7fa2de9b49343c Mon Sep 17 00:00:00 2001 From: alastair-irving <29164966+ajirving@users.noreply.github.com> Date: Sun, 29 Jul 2012 20:26:17 +0000 Subject: [PATCH] A very rough, experimental demonstration of what can be done with SSML. 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 --- latex_access/ssml.py | 38 ++++++++++++++++++++++++++++++++++++++ test_ssml | 16 ++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 latex_access/ssml.py create mode 100755 test_ssml diff --git a/latex_access/ssml.py b/latex_access/ssml.py new file mode 100644 index 0000000..0641716 --- /dev/null +++ b/latex_access/ssml.py @@ -0,0 +1,38 @@ +# ssml.py +# A part of the latex-access project at http://latex-access.sourceforge.net/ +# Author: Alastair Irving +# 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 +# +'''Experimental Module to provide speech output in SSML for latex_access.''' + + +import speech +from latex_access import get_arg + +sb='' + +class ssml(speech.speech): + def __init__(self): + speech.speech.__init__(self) + self.table["_"]=('','') + + + 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]) diff --git a/test_ssml b/test_ssml new file mode 100755 index 0000000..8eb927f --- /dev/null +++ b/test_ssml @@ -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()