python audio edits

master
Stephen Kerr 2 years ago
parent cc28cd7d65
commit 3111181fcd

@ -2,9 +2,14 @@ from playsound import playsound
from time import sleep from time import sleep
import random import random
interactivemode = 0 #0 for auto, 1 for interactive
audiopath = "C:\\Users\\user\\Documents\\Stephen\\XPUB\\week27\\audio\\"
def playasound(sound): def playasound(sound):
print("playing " + sound) print("playing " + sound)
#playsound(sound) #swap for actual playing function from josephs script #playsound(audiopath + sound) #swap for actual playing function from josephs script
sleep(5)
def menu(): def menu():
connection = int(input(""" connection = int(input("""
@ -22,23 +27,42 @@ def menu():
case 0: case 0:
menu() menu()
def randomConnection():
connection = random.randint(1,3)
match connection:
case 1:
randomMuseum()
case 2:
overlappingConnections()
case 3:
mol1and2()
def randomMuseum(): def randomMuseum():
complength = int(input("I went to the Houweling Telecom Museum, Rotterdam and recorded this for you. I wish you were there with me. print("I went to the Houweling Telecom Museum, Rotterdam and recorded this for you. I wish you were there with me.")
(pause) playasound("telecompart1.mp3")
So tell me, how many clips do you want to hear? you can press any digit on your keypad."))
if interactivemode:
playasound("telecompart2.mp3")
complength = int(input("So tell me, how many clips do you want to hear? you can press any digit on your keypad."))
else:
complength = random.randint(1,10)
while(complength>0): while(complength>0):
sound = "mus-" + "%02d" % random.randint(0, 25) + ".wav" sound = "mus-" + "%02d" % random.randint(0, 25) + ".wav"
if random.randint(0,26) == 26:
sound = "museumtour.mp3"
playasound(sound) playasound(sound)
complength -= 1 complength -= 1
def overlappingConnections(): def overlappingConnections():
side = int(input(""" print("awww, here we go... Overlapping Connections is a re-enactment of a transatlantic telephone conversation between two lovers like us in the summer of 1986. You'll love this!")
awww, here we go... Overlapping Connections is a re-enactment playasound("aww.mp3")
of a transatlantic telephone conversation
between two lovers like us in the summer of 1986. You'll love this! if interactivemode:
(pause) side = int(input("""To hear her story, press 1, his story,press 2."""))
To hear her story, press 1, his story, press 2. else:
""")) side = random.randint(1,2)
match side: match side:
case 1: case 1:
sound = "20230516-xpub-overlapping-connections-annmarie-1.wav" sound = "20230516-xpub-overlapping-connections-annmarie-1.wav"
@ -47,14 +71,16 @@ def overlappingConnections():
playasound(sound) playasound(sound)
def mol1and2(): def mol1and2():
side = int(input(""" print("""
So this is a bit secret but I trust you. I heard two teletypewriters, mol1 and mol2, having such an open conversation at the Houweling Telecom Museum, Rotterdam. Sssshhhhhh..... So this is a bit secret but I trust you. I heard two teletypewriters, mol1 and mol2, having such an open conversation at the Houweling Telecom Museum, Rotterdam. Sssshhhhhh..... """)
(pause) playasound("teletypewriter.mp3")
To hear mol1 press 2.
To hear mol2 press 1. if interactivemode:
To hear mol1and2 press 0. playasound("mol1.mp3")
To return to the main menu press 5-5-5 5-5-5 5-5. side = int(input("""To hear mol1 press 2. To hear mol2 press 1. To hear mol1and2 press 0. To return to the main menu press 5-5-5 5-5-5 5-5. To hear this menu again press 6."""))
To hear this menu again press 6.""")) else:
side = random.randint(0,2)
match side: match side:
case 2: case 2:
sound = "20230516-xpub-mol1.wav" sound = "20230516-xpub-mol1.wav"
@ -80,12 +106,20 @@ Thanks for taking the time to call me, I know you're busy at the moment. Hey Bab
----------------------------------------- -----------------------------------------
""") """)
playasound("intro.mp3")
while(True): while(True):
menu() if interactivemode:
menu() #interactive mode, disabled for now :(
else:
randomConnection() #non-interactive mode
print(""" print("""
Heeey are you still there babe? Please, stay, let's talk a little longer. """) Heeey are you still there babe? Please, stay, let's talk a little longer.
""")
playasound("intro.mp3")
print(""" print("""
----------------------------------------- -----------------------------------------

@ -2,6 +2,7 @@ from sim800l import SIM800L
import logging import logging
import os import os
import time import time
import subprocess
#logging.getLogger().setLevel(5) #logging.getLogger().setLevel(5)
sim800l = SIM800L(port='/dev/serial0', baudrate=115000, timeout=3.0) sim800l = SIM800L(port='/dev/serial0', baudrate=115000, timeout=3.0)
@ -18,12 +19,16 @@ while True:
print("some one is calling") print("some one is calling")
time.sleep(3) #wait 3 seoncds time.sleep(3) #wait 3 seoncds
sim800l.command("ATA\n") #answer the phone sim800l.command("ATA\n") #answer the phone
print("playing sound file") print("playing python file")
os.system("play test.wav &") # os.system("play test.wav &")
p = subprocess.Popen([sys.executable, 'audio.py'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
while True: while True:
#check if call is still active #check if call is still active
callisactive = sim800l.command("AT+CPAS\n") callisactive = sim800l.command("AT+CPAS\n")
if "+CPAS: 0" in callisactive: #call is not active anymore if "+CPAS: 0" in callisactive: #call is not active anymore
print ("call stopped") print ("call stopped")
os.system("killall play") # os.system("killall play")
p.terminate()
break break

Loading…
Cancel
Save