Audio in Replit (wav / au files)

I searched already and this question has been asked before (here and but there has never been a proper response that solved it:

I’m looking to play audio (.wav or .au files). This code will run fine in something like Eclipse but in Replit I get the error:

Exception in thread "main" java.lang.IllegalArgumentException: No line matching interface Clip supporting format PCM_SIGNED 44100.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian is supported. at java.desktop/javax.sound.sampled.AudioSystem.getLine( at Play.playAudio( at Play.main(

Based on my understanding using SourceForge and other sources by using AudioFormat and DataLine, the clip should be converted to a playable format.

Repl link:

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

public class Play {

    public static void main(String[] args) {
        String audioFilePath = "jump.wav";	//"path_to_your_audio_file.wav"

    private static void playAudio(String filePath) {
          try {
              File audioFile = new File(filePath);
              AudioInputStream stream = AudioSystem.getAudioInputStream(audioFile);
              AudioFormat format = stream.getFormat();  
              DataLine.Info info = new DataLine.Info(Clip.class, format);
              Clip audioClip = (Clip)AudioSystem.getLine(info);
              System.out.println("playing sound");
         catch (UnsupportedAudioFileException | LineUnavailableException | IOException e) {

To play audio you would need replit audio, but you’d have to manage /tmp/audioStatus.json manually as there’s no replit audio library for java, and it won’t work on Safari or (due to a bug) for users who don’t have access to the spotlight page.
I would recommend creating a website instead, as it’d be more performant & compatible.

1 Like

I found the updated audio tutorials for Replit here:

Unfortunately my background with Java is limited so creating a pipe and setting up the json is outside the scope of my ability. No one else have developed a solution yet either so this is very low priority.

Too bad.