diff --git a/week3/audio.py b/week3/audio.py new file mode 100644 index 0000000..ef18ed8 --- /dev/null +++ b/week3/audio.py @@ -0,0 +1,103 @@ +from playsound import playsound +from time import sleep +import random + +def playasound(sound): + print("playing " + sound) + #playsound(sound) + +def menu(): + connection = int(input(""" + For the random museum, press 1. + For the overlapping connections, press 2. + For mol1and2, press 3. + To hear this menu again, press 0.""")) + match connection: + case 1: + randomMuseum() + case 2: + overlappingConnections() + case 3: + mol1and2() + case 0: + menu() + +def randomMuseum(): + complength = int(input("How long will you listen for?")) + while(complength>0): + sound = "mus-" + "%02d" % random.randint(0, 25) + ".wav" + playasound(sound) + complength -= 1 + +def overlappingConnections(): + side = int(input(""" + Overlapping Connections is a re-enactment + of a transatlantic telephone conversation + between two lovers in 1986. + + To hear her story, press 1. + To hear his story, press 2. + """)) + match side: + case 1: + sound = "20230516-xpub-overlapping-connections-annmarie-1.wav" + case 2: + sound = "20230516-xpub-overlapping-connections-seamus-1.wav" + playasound(sound) + +def mol1and2(): + side = int(input(""" + + mol1and2 is a telephone play based on + a dialogue between three people on two + teletypewriters, originally written at + the Houweling Telecom Museum, Rotterdam. + + To hear mol1 press 2. + To hear mol2 press 1. + To hear mol1and2 press 0. + To hear mol3 press 7. + To return to the menu press 5 5 5 5 5 5 5. + To hear this menu again press 6.""")) + match side: + case 2: + sound = "20230516-xpub-mol1.wav" + case 1: + sound = "20230516-xpub-mol2.wav" + case 0: + sound = "20230516-xpub-mol1and2.wav" + case 7: + sound = "20230516-xpub-mol3.wav" + case 5: + menu() + case 6: + mol1and2() + playasound(sound) + + +print(""" +----------------------------------------- +----------------------------------------- + Welcome to the telephone opera-tor! + This is a publication of xpub ... etc +----------------------------------------- +----------------------------------------- + +""") + +while(True): + menu() + print(""" + + If you would like to listen again, + please hold. Otherwise, thank you + for listening now please hang up.""") + +print(""" +----------------------------------------- +----------------------------------------- + Thank you, have a nice day! +----------------------------------------- +----------------------------------------- + +""") \ No newline at end of file