The sound in my code is not working

Why does the sound not play? Please fix or give me code to fix :frowning:

Repl link:

import time
import pygame
from turtle import *

setup(1.0, 1.0)


running = True

sound = pygame.mixer.Sound('Minecraft.wav')
sound.set_volume(1.0)  # Play the sound indefinitely

while running:
    print("Please verify if you would like to start this program. Type 'start' to start, type 'end' to end.")
    verify = input("> ").lower()
    if verify == "start":
        print("Please wait...")
        print("Welcome to the pixel drawer. Please enjoy your time here. Use the number keys to choose drawings to view, and type 'end' to leave. If you run into problems, please restart the program.")
    elif verify == "end":
        running = False
        print("Try again.")

if not running:
    print("Thank you. Come again soon.")

I have all of the files imported into my environment that needed to be imported, just cannot hear the sounds


Hey @CyberCoder220 welcome to the forums!

Sound on Replit is very unpredictable and doesn’t work most of the time. I wouldn’t recommend trying to play sound on Replit, I encourage you to use something else if you want to use sound. Hope this helps!


Show hidden files and open the .replit file. Insert audio = true somewhere in the file.
Then, type kill 1 in the shell to reload the repl. Check the checkbox with headphones.


That’s with Replit Audio, not Pygame Audio.

1 Like

I hear the audio playing from pygame on my system.

But why would you have .replit on your system?

I meant that I forked the repl, made changes to the .replit file, and was able to get the repl’s audio working.

Oh, huh. Didn’t think that’d work with Pygame audio.

1 Like

Have you tried the module playsound?
you can use playsound as one function:

import playsound  #get it through replit packages

Hope this helps!

I’ve tried this before, playsound will not work on Replit. Did the OP manage to fix it with Pygame audio?

What did you change on my file? it may help. I was doing colab coding with some friends and am still experimenting with python and different python extensions

I already posted the changes in the 4th post: The sound in my code is not working - #4 by NuclearPasta0