1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| import sounddevice as sd
import soundfile as sf
import threading
from threading import Thread
import time
# print(sd.query_devices())
Son1= 'audio1.wav'
Son2= 'audio2.wav'
def audioFunc1():
audio1 = 'audio1.wav'
data1, fs1 = sf.read(audio1, dtype='float32')
sd.play(data1, fs1, device=5) #speaker 1
def audioFunc2():
audio2 = 'audio2.wav'
data2, fs2 = sf.read(audio2, dtype='float32')
sd.play(data2, fs2, device=6) #speaker 2
Thread(target = audioFunc1).start()
duration = len(sf.read(Son2)[0]) # duration of Son2
while True: # infinite while-loop
Thread(target = audioFunc2).start()
# pause while-loop for duration of Son2
time.sleep(duration) |
Partager