User:Jasper van Loenen/Prototyping/Soldier soldier: Difference between revisions

From XPUB & Lens-Based wiki
mNo edit summary
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
__NOINDEX__
===Soldier, Soldier===
===Soldier, Soldier===
Put this in sing.py and run it with <b>python sing.py</b><br />
Put this in sing.py and run it with <b>python sing.py</b>. Don't forget to turn on your speakers.<br />
Non-Gnome users might have to comment the first if-statement<br />
Non Gnome users might have to comment the first if-statement and its contents (the gnome-terminal part)<br />


<source lang="python">
<source lang="python">
Line 21: Line 22:


def chorus(number):
def chorus(number):
lyrics = "Soldier, soldier, will you marry me\n    "
lyrics = "Soldier, soldier, will you marry me\n    With your musket, fife and drum?"
lyrics += "With your musket, fife and drum?"
showAndSing(lyrics, "girl")
showAndSing(lyrics, "girl")
lyrics = "Oh how can I marry such a pretty little girl\n    "
lyrics = "Oh how can I marry such a pretty little girl\n    When I have "+excuses[number]+"?\n    "
lyrics += "When I have "+excuses[number]+"?\n    "
showAndSing(lyrics, "soldier")
showAndSing(lyrics, "soldier")
return
return


def fetch(number):
def fetch(number):
lyrics = "Off to the "+places[number]+" she did go\n    "
lyrics = "Off to the "+places[number]+" she did go\n    As fast as she could run\n    She brought him back the finest that was there"
lyrics += "As fast as she could run\n    "
lyrics += "She brought him back the finest that was there"
showAndSing(lyrics, "narrator")
showAndSing(lyrics, "narrator")
lyrics = "Now soldier, put "+itOrThem[number]+" on\n    "
lyrics = "Now soldier, put "+itOrThem[number]+" on\n    "

Latest revision as of 01:31, 14 March 2012

Soldier, Soldier

Put this in sing.py and run it with python sing.py. Don't forget to turn on your speakers.
Non Gnome users might have to comment the first if-statement and its contents (the gnome-terminal part)

import os
import time
import sys
os.system("clear")
if len(sys.argv)==1:
    os.system("gnome-terminal --full-screen -e  \"python goSingVoice.py 1\"")
    os.system("exit")
    exit()

print "      _____       _     _ _                _____       _     _ _           \n     /  ___|     | |   | (_)              /  ___|     | |   | (_)          \n     \ `--.  ___ | | __| |_  ___ _ __     \ `--.  ___ | | __| |_  ___ _ __ \n      `--. \/ _ \| |/ _` | |/ _ \ '__|     `--. \/ _ \| |/ _` | |/ _ \ '__|\n     /\__/ / (_) | | (_| | |  __/ | _     /\__/ / (_) | | (_| | |  __/ |   \n     \____/ \___/|_|\__,_|_|\___|_|( )    \____/ \___/|_|\__,_|_|\___|_|   \n                                   |/   \n                                                   _ \n      |  | _  _ |_     _       _  _  _ _     _  _   )\n      |/\|(_)| )|_  \/(_)|_|  |||(_|| | \/  |||(-  . \n                    /                   /            \n\n\n"

partNumber = 0;
excuses = ["no coat to put on", "no shoes to put on", "no hat to put on", "a wife and child at home"]
places = ["tailor", "cobbler", "hatter"]
itOrThem = ["it", "them", "it"]

def chorus(number):
	lyrics = "Soldier, soldier, will you marry me\n     With your musket, fife and drum?"
	showAndSing(lyrics, "girl")
	lyrics = "Oh how can I marry such a pretty little girl\n     When I have "+excuses[number]+"?\n     "
	showAndSing(lyrics, "soldier")
	return

def fetch(number):
	lyrics = "Off to the "+places[number]+" she did go\n     As fast as she could run\n     She brought him back the finest that was there"
	showAndSing(lyrics, "narrator")
	lyrics = "Now soldier, put "+itOrThem[number]+" on\n     "
	showAndSing(lyrics, "girl")
	return

def showAndSing(lyrics, voice):
	print "     "+lyrics
	if voice=="soldier":
		os.system("espeak -v +m1 -p 90 \""+lyrics+"\" 2>/dev/null")
	elif voice=="girl":
		os.system("espeak -v +f1 \""+lyrics+"\" 2>/dev/null")
	else:
		os.system("espeak -v +m5 -p 10 \""+lyrics+"\" 2>/dev/null")

for x in range(0, 4):
	chorus(x)
	if x<3:
		fetch(x)
time.sleep(5)
exit()