forked from latex-access/latex-access
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |