Skip to content
ā† Back to Community
Audio [BETA] šŸ”ˆ (EXPLORER ONLY)
Profile icon
h
has Hacker Plan
AllAwesome497

Introducing.... Audio!

Sometimes all you need to make your repl come to life is a little bit of audio, whether it's sound effects or music.

It's been requested many times that we add audio support to repl.it, so here it is.

Audio gif

We now have support for playing audio files!
Sadly, we couldn't get .mp3 files working for now, but they are in the works.
Valid file types are .wav and .aiff file.
Their bit resolution must be one of 8, 16, 24, 32, or 64; all of the common bit depths. The files can have as many audio channels as you would like, but they are combined into one channel regardles.

Please note that the files MUST BE AT 44,100 hertz or 44.1khz, as they are read at 44,100 hertz. Note that they will still play if they are not at 44.1khz, but they will be read at 44.1khz. If, for example, you have a file at 22.05khz it will be played 2x as fast as its native speed.

Currently, there are python and ts/js libs available, but if you want to create your own lib, the process is documented here.

Note that currently only exploreres can use audio.

How do I make a library? Go here.

Voters
Profile icon
AllAwesome497
Comments
hotnewtop
Profile icon
frissyn

Amazing! šŸ‘šŸ‘šŸ‘
Can't wait for .mp3 support!

Profile icon
Navinor

Did we all just get rick rolled by @AllAwesome497

Profile icon
firefish

@Warhawk947 I was worried it might be so I didn't play the clip. Lucky me.

Profile icon
AllAwesome497

@sugarfi you have to be an explorer :upside_down:

Profile icon
[deleted]

@AllAwesome497 oh well...

Profile icon
cat_optimist

@sugarfi You can become an explorer by going to the drop-down on the upper-left corner where your username is >> Account >> Drop-down Roles >> Check Explorer

Profile icon
AncientBison
Profile icon
AllAwesome497

@AncientBison I looked at your roles, and you aren't an explorer, same with @sugarfi (when i looked it up), you can become one by doing what @cat_optimist said

Profile icon
AncientBison
Profile icon
AncientBison
Profile icon
21natzil

This is so cool! Great work!

Profile icon
MarcusWeinberger
Profile icon
NarwhalFanatic

@MarcusWeinberger lol. my ears are bleeding

Profile icon
BrutalBucket

@MarcusWeinberger You just got rick rolled

Profile icon
Navinor

YES! THANK YOU SO MUCH!!!

Profile icon
[deleted]

you just got rickrolled

Profile icon
techgeek680

Dude. Even tho I'm explorer mode It says error

Profile icon
stubaduble

How do you become an explorer?

Profile icon
ChezCoder

FINALLY!!! This is why we love repl.it <3

Profile icon
HackermonDev

OwO. Wait it doesn't work.
image

Profile icon
AllAwesome497

@PDanielY As i noted at the end of the post, you have to be an explorer.

Profile icon
HackermonDev

@AllAwesome497 oh, my bad

Profile icon
lampa84da

I create a source = audio.play_file('assets/sound.wav', 1.0, True, -1). I want my loop to play infinite but it doesn't work. Please help me with this.

Profile icon
naren2008

awsome man !!!

Profile icon
Wilke000
Profile icon
ChezCoder

@IndyCarter you need explorer mode

Profile icon
Wilke000

What dat @ChezCoder?

Profile icon
ChezCoder

@IndyCarter go to https://repl.it/account#roles , scroll down, click "roles", and check EXPLORER :D

Profile icon
Wilke000

Ok @ChezCoder, thanks!

Profile icon
ChezCoder
Profile icon
[deleted]

its not working for me.

Profile icon
zplusfour

there is an error

Profile icon
Wilke000

Cool!

Profile icon
AtriDey

Is there an option to wait for the audio to play before moving on to he next line of code?

Profile icon
ChezCoder

@AtriDey try this:

import time audio.play('audio.wav') time.sleep(LENGTH_OF_AUDIO)
Profile icon
AtriDey

Glad I checked the audio file before running the program. Replaced with Win7 startup sound.

Profile icon
AtriDey

Good, now I can actually do half my projects.

Profile icon
ChezCoder

@AllAwesome497 i need to type any command 2 times for it to work for some reason

Profile icon
ChezCoder

@AllAwesome497 also, if I go below 0% volume, the volume starts going up again.

Profile icon
AllAwesome497

@ChezCoder I know, if you look into pcm waves it doesnt matter if you flip the values. Its just volume * sample, so if every sample is the flipped polarity, it still sounds the same.

Profile icon
ChezCoder

@AllAwesome497 ok. But you have to do something twice for the music to work. Like enter twice, the up command twice to increase volume, etc

Profile icon
ChezCoder

@AllAwesome497 please help, im using audio in my project but its playing for like 2 seconds and then doesnt play anymore

Profile icon
ChezCoder

@AllAwesome497 why do the moderators like never reply

Profile icon
AllAwesome497

@ChezCoder sorry was working on things. Can you link me to it?

Profile icon
ChezCoder

@AllAwesome497 sorry for bothering you. Apparently, source = audio.play('audio.wav') is asynchronous and meant that as soon as it played, the repl ended and it stopped. Can you make an option to choose wither you want to play the music synchronously or not?

Profile icon
ChezCoder

@AllAwesome497 one more problem, loops aren't working. Also, is there a way to restart the track? (set the time back to 0:00)

Profile icon
AllAwesome497

@ChezCoder there isnt a way to rewind... And can you link me to the repl where loops aren't working?

Profile icon
ChezCoder

@AllAwesome497 i want to keep this secret for now so ill delete after you see the code

Profile icon
ChezCoder

@AllAwesome497 something isn't working with the audio again, its not pausing :(

Profile icon
ChezCoder

They probably where so concentrated on getting it work that when they finished, they looked at the code and was like dammit we forgot mp3

Profile icon
AllAwesome497

@ChezCoder nope. Actually, mp3 support was a plan from the start, I just didn't get to it.

Profile icon
ChezCoder

@AllAwesome497 lol it was a joke :D

Profile icon
thedankboi

can we use repl.it audio with webbot?

Profile icon
mwilki7

ah .wav files, the goldsrc glory days have returned

Profile icon
studentAlfredAl

This is really amazing! I have no words other than it's just really good! :)

Profile icon
glitchish

Yes! Finally Thank You!

Profile icon
NarwhalFanatic

:O Was just trying to import playsound but you have solved my problems

Profile icon
BrutalBucket

Works pretty well
audiopy

Profile icon
xxpertHacker

What's wrong with .mp3s? Is it possible to just direct all audio coming from a Repl the the user's browser?

Profile icon
CoolJames1610

so cool