Nov-03-2020, 03:54 PM
You can start the process with the
subprocess.Popen()
constructor. No thread is needed as you are running an external process.import subprocess as sp while True: i = (i + 1) date = datetime.now().strftime('%d-%m-%y %H-%M-%S') print(i, date) select = input('Press 1 to send random MP3 \n\r') if select == '1': with sp.Popen([ "mpg123", "-o", "alsa:hw:2,0", random.choice(TestSound)]) as proc: sleep(0.2) # small delay perhaps Check_Voltage() else: print ('no sound will play , wait for next time! ') sleep(5)