我在Windows 64位上使用python 3.5,我一直试图在我的代码中加入一些声音。
我在spyder中尝试了两个程序,但我仍然无法让它工作。这两个程序都运行没有错误,但我听不到任何声音。我认为问题可能出在spyder本身?我不确定。我尝试重置spyder设置,但它仍然无法正常工作。有人可以帮忙吗?
两个代码:
import pygame
#import os
pygame.init()
pygame.mixer.init()
sounda= pygame.mixer.Sound("b001c012.wav")
#os.system
sounda.play()
import os
from datetime import datetime
debug = True
def playASound(x):
if debug == True:
print(x,end = ' - ')
print(daysound[x])
todaysound = 'aplay' + sayDayDirectory + daysound[x] + '.wav -R 1'
os.system(todaysound)
sayDayDirectory = '/home/pi/exercise\ files/dayOfWeekSounds/'
daysound = ['monday','tuesday','wednesday','thursday','friday','saturday','sunday']
todaysDate = datetime.now()
todaysDay = datetime.weekday(todaysDate)
playASound(todaysDay)
if debug == True:
print('other sounds are ')
for n in range(0,7):
playASound(n)