User:Jasper van Loenen/Prototyping/Soldier soldier

From XPUB & Lens-Based wiki

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

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     "
	lyrics += "With your musket, fife and drum?"
	showAndSing(lyrics, "girl")
	lyrics = "Oh how can I marry such a pretty little girl\n     "
	lyrics += "When I have "+excuses[number]+"?\n     "
	showAndSing(lyrics, "soldier")
	return

def fetch(number):
	lyrics = "Off to the "+places[number]+" she did go\n     "
	lyrics += "As fast as she could run\n     "
	lyrics += "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()