User:Lieven Van Speybroeck/Prototyping/8-Soldier: Difference between revisions
mNo edit summary |
mNo edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 3: | Line 3: | ||
#!/usr/bin/python | #!/usr/bin/python | ||
# | # lists of clothes, places and reasons | ||
clothes = ["coat","shoes","hat"] | clothes = ["coat","shoes","hat"] | ||
people = ["tailor","cobbler","hatter"] | people = ["tailor","cobbler","hatter"] | ||
first,last = ["When i have no | first,last = ["When i have no {0} to put on?","When I've a wife and child at home?"] | ||
# | # recurring parts of the two choruses | ||
chorus1 = "Soldier, soldier, will you marry me\nWith your musket, fife and drum?\nOh how can I marry such a pretty little girl\n | chorus1 = "Soldier, soldier, will you marry me\nWith your musket, fife and drum?\nOh how can I marry such a pretty little girl\n{0}\n\n" | ||
chorus2 = "Off to the | chorus2 = "Off to the {0} she did go\nAs fast as she could run\nShe brought him back the finest that was there\nNow soldier, put them on\n" | ||
# | # play that song! | ||
for i in range( | for i in range(3): | ||
print chorus1 | print chorus1.format(first.format(clothes[i])),chorus2.format(people[i]) | ||
print chorus1 | print chorus1.format(last) | ||
</source> | </source> | ||
Latest revision as of 15:02, 21 October 2011
soldier.py:
#!/usr/bin/python
# lists of clothes, places and reasons
clothes = ["coat","shoes","hat"]
people = ["tailor","cobbler","hatter"]
first,last = ["When i have no {0} to put on?","When I've a wife and child at home?"]
# recurring parts of the two choruses
chorus1 = "Soldier, soldier, will you marry me\nWith your musket, fife and drum?\nOh how can I marry such a pretty little girl\n{0}\n\n"
chorus2 = "Off to the {0} she did go\nAs fast as she could run\nShe brought him back the finest that was there\nNow soldier, put them on\n"
# play that song!
for i in range(3):
print chorus1.format(first.format(clothes[i])),chorus2.format(people[i])
print chorus1.format(last)
then run:
$ soldier.py | espeak -ven+f2 -p80
et voila: lovely monotone folk song