r/PyScript • u/Calm-Basil • Oct 07 '22
Question about pyscript
Could I please ask of there is any way for pyscript to cause the html page to play a sound when an if statement is true?
I've tried googling and wasn't able to find an answer to this.
Play sound nor pydub works.
3
Upvotes
View all comments
Show parent comment
1
u/Best_Championship835 Feb 24 '23
u/TheSwami Do you happen to know why this is not working then? Thanks.
<script defer="" src="https://pyscript.net/alpha/pyscript.js"></script><py-script>from js import alert, prompt, localStorage, window, confirm, Audioimport timeimport randomimport rehorn = Audio.new("https://github.com/goldfire/howler.js/blob/master/examples/3d/assets/sprite.mp3?raw=true")user_answer = str(prompt("play? (yes) or (no)"))if user_answer.lower() == 'yes':horn.play()print('yes')print('end')</py-script>