0

I'm trying to get the Eevee.wav to play when both the key is clicked and PetHappyTF is 1. Anytime I hit E it doesnt play. I know the audio is fine because when i remove the first if it works. so... SOS!

#importing stuff
from playsound import playsound
import keyboard
import speech_recognition
import pyttsx3
import pyaudio
import time

#data load
PetHappyTF = 1

#first bootup
playsound('Bootup.wav')

#Program
while True:
    def countdown(PetHappyCD):
        while PetHappyCD > 0:
            PetHappyCD -= 1
            time.sleep(1)
        PetHappyTF= 1    
            
            
if PetHappyTF == 1:
    if keyboard.is_pressed("E"): #Keystroke standing in for touch sensor. Eevee.wav standing in for Happy sound
        playsound('Eevee.wav')
        PetHappyTF = 0

seconds = 15
seconds = int(seconds)
countdown(seconds)
Pig Empire
  • 11
  • 1
  • 1
    You need to re-examine the indentation in your code. It looks like your first `while` loop is just repeatedly defining a function; nothing else happens, nothing else is called. – Sylvester Kruin Feb 27 '22 at 21:56
  • While this wasn't it it actually made me realize I had my While true in the wrong place. Thanks – Pig Empire Feb 27 '22 at 23:05

0 Answers0