pin number changed

This commit is contained in:
cpu
2023-12-12 19:52:52 +01:00
parent 8b0fd02e09
commit 1522032a36

View File

@@ -11,9 +11,9 @@ else:
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
BUTTON_TIMEOUT = ( BUTTON_TIMEOUT = (
30 # pressing and holding the button longer then e.g. 2 seconds terminates playing 30 # button release timeout terminates playing
) )
PIN = 17 # listen to changes on this GPIO PIN = 27 # listen to changes on this GPIO pin
GPIO.setmode(GPIO.BCM) # use BCM pin layout GPIO.setmode(GPIO.BCM) # use BCM pin layout
GPIO.setwarnings(False) GPIO.setwarnings(False)
@@ -39,7 +39,7 @@ def play_presny_cas():
def play_beep(): def play_beep():
print("Playing beep.wav") print("Playing beep.wav")
subprocess.call(["aplay", "beep.wav"]) subprocess.run(["aplay", "beep.wav"], check=True)
def get_credentials(): def get_credentials():
@@ -56,16 +56,11 @@ def generate_presny_cas():
username, password = get_credentials() username, password = get_credentials()
subprocess.call( subprocess.call(
[ [
"curl", "curl", "--silent", "-u", f"{username}:{password}",
"--silent",
"-u",
f"{username}:{password}",
"--get", "--get",
"--data-urlencode", "--data-urlencode", f"text={text}",
f"text={text}",
"https://tts.virtonline.eu/api/tts", "https://tts.virtonline.eu/api/tts",
"--output", "--output", "presny_cas.wav",
"presny_cas.wav",
] ]
) )
print("Generated presny_cas.wav") print("Generated presny_cas.wav")
@@ -104,6 +99,6 @@ try:
except Exception as e: except Exception as e:
print("Caught exception: ", e) print("Caught exception: ", e)
sys.exit()
finally: finally:
GPIO.cleanup() GPIO.cleanup()