Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it easy to play audio input in Audio pane #7035

Open
MarcSkovMadsen opened this issue Jul 28, 2024 · 1 comment
Open

Make it easy to play audio input in Audio pane #7035

MarcSkovMadsen opened this issue Jul 28, 2024 · 1 comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Milestone

Comments

@MarcSkovMadsen
Copy link
Collaborator

MarcSkovMadsen commented Jul 28, 2024

I believe its hard to use the Audio pane as it does not support

  • raw bytes
  • in memory (BytesIO) files
  • data urls
  • webm format
  • an empty string or empty bytes string as input.
    • It does support None. It should behave the same for other "empty" objects. Because that is what you might get back from FileInput or some custom Audio input.

Please support these. And consider adding the similar support for the Video pane.

Motivation

I've been with working on the missing AudioInput widget. By default you get audio in the browser in webm format. The easist is to transfer this as a data url to the python side. But the data url no matter whether its webm, wav or any other format is not supported by the Audio pane.

Thus you will have to convert it to replay it.

If you do what the FileInput does, i.e. convert to the raw bytes, then the Audio player cannot play these. Thus its also hard to use the Audio pane with the FileInput widget.

As far as I can see you will have to save to a temporary file on disk and provide the path to the file. This is cumbersome and inefficient.

But as webm is not supported by Audio pane you will have to convert to a supported format. As far as I can see this requires you to install ffmpeg which is not always possible for example in a controlled enterprise environment. If if you try to use ffmpeg wasm in the browser you will also have to figure out how to support a web worker in a custom JScomponent or similar.

All in all its very hard for a "normal" data scientist to input Audio from JSComponent or FileInput and play it in Audio pane.

@MarcSkovMadsen MarcSkovMadsen added TRIAGE Default label for untriaged issues type: enhancement Minor feature or improvement to an existing feature and removed TRIAGE Default label for untriaged issues labels Jul 28, 2024
@MarcSkovMadsen MarcSkovMadsen added this to the Wishlist milestone Jul 28, 2024
@MarcSkovMadsen MarcSkovMadsen changed the title Make it easy to use Audio Pane with audio input Make it easy to play Audio input in Audio pane Jul 28, 2024
@MarcSkovMadsen MarcSkovMadsen changed the title Make it easy to play Audio input in Audio pane Make it easy to play audio input in Audio pane Jul 28, 2024
@dillonroach
Copy link

@MarcSkovMadsen drive by comment, as I saw this while looking for something else; I've done some rough-and-ready audio loading with panel using librosa as the intermediary (e.g. below is dropped audio file to playback pane)

            file_name, file_content = next(iter(file_dropper.value.items()))
            audio = librosa.load(io.BytesIO(file_content))
            audio_pane.sample_rate = sample_rate=audio[1]
            audio_pane.object = np.int16(np.array(audio[0],dtype=np.float32)* 32767)

That's at least a way to get from raw (file_content) or bytesIO (skipping step one heh) object to audio pane out. Nobody wants another requirement, naturally, so you'd want to reproduce the librosa.load basically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants