Enhance the speech output your voice application with the use of templates.
Tutorial about creating a python packages:
- Python 3
Follow the instruction in der Docs and Blog:
$ python -m venv venv
$ echo 'venv' > .gitignore
$ source venv/bin/activate
$ source deactivate
To select a specific environment, use the Command Palette (⇧⌘P).
Type in Python: Select Interpreter
and select ./venv/bin/python
. Docs
$ pip install -r requirements.txt
$ pip freeze > requirements.txt
$ git add requirements.txt
$ python setup.py bdist_wheel
$ pip install -e .
$ pytest
$ python test/templating_test.py
Install the package via pip:
$ pip install git+https://github.com/ONSEIGmbH/onsei-templating#egg=templating
Import the PromptTemplate
in each script, where speech output is needed.
Set the path to the template file (.yaml
). Filename can be changed.
To get the speech output use the se the render
function as shown below.
from templating import PromptTemplate
t = PromptTemplate('template/example.yaml')
print(t.render('hi')) # Hello World!
print(t.render('hi_name',name='MyName')) # Hello MyName!