Updates from the Repl.it team about the product

← Back to all posts
AllAwesome497 (337)

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.

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.

Winter192020 (4)

you just got rickrolled

techgeek680 (70)

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

stubaduble (13)

How do you become an explorer?

Thecrowbar1234 (146)

its not working for me.

ZDev1 (474)

there is an error

AtriDey (168)

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

ChezCoder (1500)

@AtriDey try this:

import time

AtriDey (168)

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

AtriDey (168)

Good, now I can actually do half my projects.

ChezCoder (1500)

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

ChezCoder (1500)

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

AllAwesome497 (337)

@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.

ChezCoder (1500)

@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

ChezCoder (1500)

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

ChezCoder (1500)

@AllAwesome497 why do the moderators like never reply

AllAwesome497 (337)

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

ChezCoder (1500)

@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?

ChezCoder (1500)

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

AllAwesome497 (337)

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

ChezCoder (1500)

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

ChezCoder (1500)

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

ChezCoder (1500)

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

AllAwesome497 (337)

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

CodingAndMemes (29)

can we use repl.it audio with webbot?

ChezCoder (1500)

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

mwilki7 (1078)

ah .wav files, the goldsrc glory days have returned

studentAlfredAl (464)

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

Warhawk947 (519)

Did we all just get rick rolled by @AllAwesome497

firefish (412)

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

ridark (49)

Yes! Finally Thank You!

NarwhalFanatic (26)

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

xxpertHacker (381)

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

TheForArkLD (711)

Can we use it in NodeJS?
nvm this is cool!

AllAwesome497 (337)

@TheForArkLD yea you can, i added a link to the docs with an example using the node js / ts lib.

TheForArkLD (711)

@AllAwesome497 thanks and

Supports mp3 please...

HahaYes (1176)

When they support everything but the only one that I like is missing. ........... (oh no mp3)

CoolTomato (13)

@HahaYes wav is objectively better so it's good that they gave us the best format first... ogg would be nice for game audio tho

Warhawk947 (519)