alsa is a hammer

This commit is contained in:
Sophie Schiller 2024-05-19 16:29:28 +02:00
parent f24f5dbc56
commit 612a61d8b8
2 changed files with 5 additions and 4 deletions

7
app.py
View file

@ -3,7 +3,8 @@ from os.path import join
from flask import Flask, render_template
from markupsafe import escape
from playsound import playsound
from subprocess import check_output
app = Flask(__name__)
@ -14,6 +15,8 @@ for f in samplefiles:
samples.append(f.replace(".wav", ""))
output = check_output(['amixer', 'sset', 'Master', 'unmute'])
@app.route("/")
def hello():
return render_template("index.html", samples=samples)
@ -22,7 +25,7 @@ def hello():
@app.route("/play/<sample>")
def door(sample):
if sample in samples:
playsound(join("samples", f"{sample}.wav"))
play_output = check_output(['aplay', '-D', 'hw:0,0', join("samples", f"{sample}.wav")])
return f"<h1>{escape(sample)}!</h1>"
else:
return "no such sample"

View file

@ -1,4 +1,2 @@
Flask
Gunicorn
playsound
pygobject