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

Support audio controls in Notebook Renderer #118275

Closed
DonJayamanne opened this issue Mar 5, 2021 · 35 comments
Closed

Support audio controls in Notebook Renderer #118275

DonJayamanne opened this issue Mar 5, 2021 · 35 comments
Assignees
Labels
feature-request Request for new features or functionality on-testplan
Milestone

Comments

@DonJayamanne
Copy link
Contributor

Request: Add support for Audio Control in Notebook Renderer.

We (Jupyter Extension) can accept the PR, however this would mean the Jupyter extension now has a custom renderer for HTML.
And I'm not too keen on owning rendering all HTML content in Notebook renderers (I know VS Code has custom code to handle a lot of the HTML content, links, etc).

Suggestion

  • Please can we re-visit this issue
  • Is it possible to provide some way for the Notebook to override the preferred renderer based on the content?
    • I.e. I'd prefer to always use the built in renderer for HTML
    • However if VS Code will not support wav natively, then we can override the preferred renderer and use the one we ship.

@rebornix /cc

@mcmar
Copy link

mcmar commented Mar 5, 2021

This entire issue could be obviated if you just ship a build with ffmpeg. That's probably the preferable solution to all this.
See:
#32540
#54097
#66050

@robinhad
Copy link

robinhad commented Mar 6, 2021

I think a good solution will be to build VSCode with some kind of "libre" ffmpeg - with only wav, ogg, vorbis for audio and AV1 for video.
It will facilitate the most common use cases for audio/video processing and will not bloat VSCode too much.

@rebornix
Copy link
Member

rebornix commented Mar 6, 2021

Assigning to @deepak1556 and @mjbvz as this is more about audio control in webview.

@mcmar
Copy link

mcmar commented Mar 6, 2021

I just want to point out that the whole reason we're here today is because ffmpeg inclusion was previously stonewalled multiple times and we were told to create an HTML workaround.
So here we are with a workaround for WAV audio because a codec technically isn't required for WAV audio. Now people are complaining that the workaround is complex. That's fair, but I just don't want to get stuck in-between two solutions where we end up doing nothing. I hope we can all commit to picking between either the HTML-based WAV audio workaround or adding ffmpeg to the build. It's really not fair to users to stonewall this issue forever.

@DonJayamanne
Copy link
Contributor Author

Now people are complaining that the workaround is complex.

I apologise for making it sound if the solution implemented by @robinhad is complex. That was not my intention at all.

@mcmar
Copy link

mcmar commented Mar 6, 2021

@DonJayamanne Sorry, I should rephrase that. Just want to make sure that we do something here.
Options so far:

  1. ffmpeg
  2. slim compiled ffmpeg (see here)
  3. HTML-based workaround

@rchiodo
Copy link
Contributor

rchiodo commented Mar 9, 2021

In case anybody is looking for the reason why this is important for jupyter customers, here's our original issue:
microsoft/vscode-jupyter#1012

@robinhad
Copy link

Hello!
Is there any news regarding this issue?

@sporkl
Copy link

sporkl commented May 20, 2021

I haven't tried this, but it looks like it's possible to add the complete ffmpeg libraries oneself as a workaround. VSCodium/vscodium#152 (comment) .

@deepak1556 deepak1556 added this to the June 2021 milestone May 20, 2021
@RandomFractals
Copy link

well, some devs using Py and JS notebooks for ML might want to have those audio and video capabilities, including webcam access.

I tested this in JS notebooks and def. would like to play them in vscode some day, including youtube tutorials, and do some extensions with webcam ...

vscode-webcam-2

youtube-iframe-in-code

vscode-sandbox

@leoauri
Copy link

leoauri commented Jun 23, 2021

I would really appreciate this being implemented, as it is blocking me from using the jupyter extension. Cheers

@RandomFractals
Copy link

RandomFractals commented Jun 24, 2021

I'd be happy to provide more code samples and test JS notebooks from my end for vscode team to review and come up with a good solution.

I don't think what's been discussed and proposed as a workaround solution in Jupyter repo @rchiodo linked us to is the best long term approach to resolve this, but thank you for linking them.

@deepak1556 deepak1556 modified the milestones: June 2021, July 2021 Jun 28, 2021
@deepak1556 deepak1556 modified the milestones: July 2021, August 2021 Jul 26, 2021
@deepak1556 deepak1556 removed this from the August 2021 milestone Aug 23, 2021
@RandomFractals
Copy link

WebCodecs is now part of Chrome 94 Beta: https://blog.chromium.org/2021/08/chrome-94-beta-webcodecs-webgpu.html

I think that's the spec to watch and webGPU for compute to enable audio/video codecs apis in vscode when Chromium is updated to that version.

@rgrimwood

This comment was marked as spam.

@p-i-
Copy link

p-i- commented Jun 2, 2022

There is clearly huge demand for this functionality.
At time of writing, 175 upvotes on the OP.
It's aggravating to have to move between VSCode's .ipynb editor and Jupyter's browser-based .ipynb editor, just to play audio inline.
Nowhere can I see it clearly stated exactly what the block is.
@deepak1556 mentions "Legal Team". Is it an ffmpeg-licensing issue?
The usual (AFAIU) way around such issues is to provide the user a button to download the component with the offending license, thus making it THEIR responsibility, and not that of VSCode/Microsoft.
Another option would be to contact the owner(s) of FFMPEG directly and request they make an exception.

But why not simply create code that plays a raw audio buffer (e.g. mono/sterero np.array)? VSCode is a Desktop application targeting Win/macOS/Linux. How hard can that be? You could look into the JUCE repo to see how they have achieved it. And then leave the conversion of any other format into raw PCM up to the Python community, such that it can be resolved with an import?

I look forward to a situation where VSCode Notebook is able to act as a complete replacement for Jupyter Notebook. You are so close!

@PatrykMiszczak
Copy link

But why not simply create code that plays a raw audio buffer (e.g. mono/sterero np.array)

Yes, playing from the buffer will be enough for most cases. I think most people will use this to check the results of their processing

@p-i-
Copy link

p-i- commented Jun 2, 2022

^ I've created a feature-request for a barebones functionality to play a mono/stereo np.array from a cell output.
I think this should be addressed separately from the much larger task of a fully-fledged media player.
If the team would care to provide this, it would give us audio engineers enough to work with.
Forever grateful for the tremendous work of the VSCode team, and in particular the .ipynb unit. It's a splendid technology.

@lukepighetti
Copy link

Ticket #151149 has been selected as candidate for backlog. If we upvote it, it will go into the backlog. It requests the ability to play raw waveforms in VSCode.

@Myslicki
Copy link

Myslicki commented Jul 3, 2022

image

VSCode moved it to their backlog as of July 2nd. Progress!
Reference: #151149

facebook-github-bot pushed a commit to facebookresearch/multimodal that referenced this issue Aug 3, 2022
Summary:
Add notebook tutorial for VideoCLIP evaluation using pretrained checkpoint.
- `retrieval/evaluation.ipynb`: notebook with step-by-step instructions for setting up model, calling model, and getting predictions

Pull Request resolved: #193

Test Plan:
Run notebook

Note that vscode is incapable of rendering video/audio in notebooks (see [issue](microsoft/vscode#118275)) and github doesn't display the videos in output cells. Embedded videos can be played in google colab ([link to this tutorial in colab](https://colab.research.google.com/drive/1zCU0KPzFKns07aVbSlN_1c8gtKXG0ke2?usp=sharing)) or in jupyter lab.

To install jupyterlab, convert your `torch-multimodal` conda env into a kernel, and launch jupyter lab:
```
(base) conda install -c conda-forge jupyterlab
(base) conda activate torch-multimodal
(torch-multimodal) conda install ipykernel
(torch-multimodal) ipython kernel install --user --name=torch-multimodal
(torch-multimodal) conda deactivate
(base) jupyter lab
```

Reviewed By: langong347

Differential Revision: D38362846

Pulled By: sophiazhi

fbshipit-source-id: aa18739cd02270ce80524d31cfd1a43b7e66287c
edward-io pushed a commit to edward-io/multimodal that referenced this issue Aug 5, 2022
Summary:
Add notebook tutorial for VideoCLIP evaluation using pretrained checkpoint.
- `retrieval/evaluation.ipynb`: notebook with step-by-step instructions for setting up model, calling model, and getting predictions

Pull Request resolved: facebookresearch#193

Test Plan:
Run notebook

Note that vscode is incapable of rendering video/audio in notebooks (see [issue](microsoft/vscode#118275)) and github doesn't display the videos in output cells. Embedded videos can be played in google colab ([link to this tutorial in colab](https://colab.research.google.com/drive/1zCU0KPzFKns07aVbSlN_1c8gtKXG0ke2?usp=sharing)) or in jupyter lab.

To install jupyterlab, convert your `torch-multimodal` conda env into a kernel, and launch jupyter lab:
```
(base) conda install -c conda-forge jupyterlab
(base) conda activate torch-multimodal
(torch-multimodal) conda install ipykernel
(torch-multimodal) ipython kernel install --user --name=torch-multimodal
(torch-multimodal) conda deactivate
(base) jupyter lab
```

Reviewed By: langong347

Differential Revision: D38362846

Pulled By: sophiazhi

fbshipit-source-id: aa18739cd02270ce80524d31cfd1a43b7e66287c
@isidorn isidorn assigned isidorn and unassigned chrisdias Aug 12, 2022
@isidorn
Copy link
Contributor

isidorn commented Aug 12, 2022

@deepak1556 plans to add ffmpeg with the following codecs to VS Code insiders:

  • Vorbis
  • Flac
  • H.264
  • VP8
  • WAV
  • MP3
  • Ogg

This should allow the majority of notebook scenarios from this issue. We would really appreciate if you try it out and let us know if there are scenarios which are still not working since they might require codecs which we are still not shipping.

I will comment here once we release VS Code insiders with these changes next week.

Thank you 🙏

@isidorn isidorn modified the milestones: On Deck, August 2022 Aug 12, 2022
facebook-github-bot pushed a commit to facebookresearch/multimodal that referenced this issue Aug 18, 2022
Summary:
Revise VideoCLIP tutorial notebook to better adhere to guidelines for official pytorch tutorials ([internal wiki](https://www.internalfb.com/intern/wiki/PyTorch/Teams/PyTorch_Doc_Engineering/PyTorch_Tutorials_QuickStart/)).

Pull Request resolved: #242

Test Plan:
Run notebook

Note that vscode is incapable of rendering video/audio in notebooks (see [issue](microsoft/vscode#118275)) and github doesn't display the videos in output cells. Embedded videos can be played in google colab ([link to this tutorial in colab](https://colab.research.google.com/drive/1-J2BU-MDdOpnYKjzgvhsme4C1MAjyVsb#scrollTo=ZJCnp2DFRILI)) or in jupyter lab.

To install jupyterlab, convert your `torch-multimodal` conda env into a kernel, and launch jupyter lab:
```
(base) conda install -c conda-forge jupyterlab
(base) conda activate torch-multimodal
(torch-multimodal) conda install ipykernel
(torch-multimodal) ipython kernel install --user --name=torch-multimodal
(torch-multimodal) conda deactivate
(base) jupyter lab
```

Reviewed By: langong347

Differential Revision: D38797861

Pulled By: sophiazhi

fbshipit-source-id: 7dd08bb3c5eacba9fcf9fd9d3c715082a6406580
@isidorn
Copy link
Contributor

isidorn commented Aug 19, 2022

Today's VS Code Insiders has all the codecs I have listed above ☝️ thanks to @deepak1556 and @alexeykuzmin. Please try it out with various Notebook scenarios and do let us know if some flows are still not working.

I will still keep this issue open to collect feedback, and we can close it if things look good.

Thank you 🙏

@bliep
Copy link

bliep commented Aug 19, 2022

Fantastic work !

It (also) plays uncompressed signals:

import IPython.display as ipd
import numpy as np
fs = 16000.
ipd.Audio(np.sin(2*np.pi*440*np.arange(5 * fs)/fs), rate=fs)

@isidorn
Copy link
Contributor

isidorn commented Aug 22, 2022

Closing this issue as the planned work is done. And in case some scenarios are still not working do let us know or just open a new issue and ping me @isidorn on it. Thank you very much.

@isidorn isidorn closed this as completed Aug 22, 2022
@isidorn isidorn added feature-request Request for new features or functionality on-testplan labels Aug 22, 2022
@lukepighetti
Copy link

Big thank you for the support here

@sugoidesune
Copy link

Didn't work, updated vscode and the feature is here and working! Thank you all! ❤🎉🎉

@github-actions github-actions bot locked and limited conversation to collaborators Oct 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality on-testplan
Projects
None yet
Development

No branches or pull requests