Last active
February 28, 2016 09:10
-
-
Save pkra/f1da676a8a542f3afe69 to your computer and use it in GitHub Desktop.
SpeechRuleEngine in Python
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
# 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