Skip to content

Instantly share code, notes, and snippets.

@pkra
Last active February 28, 2016 09:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkra/f1da676a8a542f3afe69 to your computer and use it in GitHub Desktop.
Save pkra/f1da676a8a542f3afe69 to your computer and use it in GitHub Desktop.
SpeechRuleEngine in Python
# Usage: python sre.py mml.txt
import os
import sys
from execjs import get
runtime = get('Node')
context = runtime.compile('''
module.paths.push('%s');
var sre = require('speech-rule-engine');
sre.setupEngine({semantics: true, domain: "mathspeak", style: "brief"});
function speech(mml){
return sre.toSpeech(mml);
}
''' % os.path.join(os.path.dirname(__file__),'node_modules'))
def speech(mml):
return context.call('speech',mml)
def main():
print speech(open(sys.argv[-1],'r').read())
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment