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 uploads on iOS? #4021

Closed
drscotthawley opened this issue May 1, 2023 · 16 comments · Fixed by #4071
Closed

Support audio uploads on iOS? #4021

drscotthawley opened this issue May 1, 2023 · 16 comments · Fixed by #4071
Labels
bug Something isn't working
Milestone

Comments

@drscotthawley
Copy link

  • [ x] I have searched to see if a similar issue already exists.

Following up on this Discussion and request to add Issue by @abidlabs :

https://github.com/gradio-app/gradio/discussions/3998

iOS is a little funny and while the way Gradio configures Audio input elements should be ok, somehow it's not.

Pasting from the above-mentioned Discussion:

Hi, I have a new audio-in, audio-out Gradio demo I'm working on (sorry, can't share any details yet).

But I notice that if I'm on my iOS devices, when I press the audio upload box ("Drop Audio here -or- click to Upload") and pick "Choose File", and go through the list of files to upload into the audio box, all the (.wav, .mp3, .aiff) audio files are "greyed out", i.e. I'm not allowed to select any to upload. Doesn't matter if I'm selecting files in iCloud Drive, or on my Device, or in Dropbox: All audio files are non-selectable.

I'm not sure if this is an iOS limitation or a Gradio issue....? Can anyone help?

This happens when using Safari or Chrome on my iPhone or iPad, pretty recent iOS versions. Brave browser on latest iPad version behaves similarly.

(No problems running from desktop!)


Through experimentation*, I find that this seems to be a bug(/feature) in iOS whereby HTML input field with accept="audio/*" does not actually allow audio to be selected on iOS.

If Gradio wanted support audio uploads on iOS, one workaround on your end end could be to either change the accept string generated for the input field , either to accept="/" or to list each allowed file extension e.g accept="audio/mp3, audio/wav,..." etc. @abidlabs @yvrjsharma

(You shouldn't need to do this but iOS is a part of the market, and this change would still be compatible with other devices.)

(*Source. Trying it manually, on this page: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file )

@abidlabs abidlabs added the bug Something isn't working label May 1, 2023
@abidlabs
Copy link
Member

abidlabs commented May 1, 2023

Thanks for creating the issue @drscotthawley will look into it!

@abidlabs
Copy link
Member

abidlabs commented May 1, 2023

Btw would you like to open a PR since it looks like you’ve already started with the solution? Otherwise we can do it on our end

@abidlabs abidlabs added this to the 3.x milestone May 1, 2023
@drscotthawley
Copy link
Author

@abidlabs Re. the PR, I'd be happy to try but I'm not sure where in your code you're supplying that (MIME?) type information.

I took a look at the Audio element in components.py but didn't find any place to implement the change, e.g. I couldn't find "accept=" anywhere.

If one of your engineers could suggest a place to look, I could try again.

@abidlabs
Copy link
Member

abidlabs commented May 4, 2023

Thanks @drscotthawley, what a coincidence! @aliabid94 on the Gradio team just opened a PR for this if you'd like to take a look: #4071

@drscotthawley
Copy link
Author

@abidlabs Oh yes!!! Thanks @aliabid94!
I went to the PR and tried the "all demos" example on my iPhone and it worked fine! :-) We could close this Issue with a "fixed in PR #4071" ...?
maybe I'll wait for the merge and test it in my app first. ;-)

@drscotthawley
Copy link
Author

Oh darn, I pulled the PR and put it in my app but got this message:

ValueError: Did you install Gradio from source files? Share mode only works when Gradio is installed through the pip package.

@abidlabs Do let me know when the pip package gets updated! :-)

@drscotthawley
Copy link
Author

drscotthawley commented May 7, 2023

Related, FYI @abidlabs @aliabid94 : This Issue was about Uploading audio on iOS. What about Downloading audio on iOS?....

Answer: Turns out there appears to be no way to get the HTML5 Audio element controls on iOS to support a Download option. Period.

Users who want to Download audio results will either have to stick to desktop browsers, or developers of Gradio demos who want to support audio downloads on iOS can either supply their own separate "Download Audio" button, or just post an HREF-style link for the output audio file (presumably by using the elem_id of a gr.Markdown() element.)

Just registering that information here in case anyone else asks.

@Alanp777
Copy link

Alanp777 commented May 7, 2023

@drscotthawley do you know if we will be able to playback audio in ios? my users have been complaining about that, would like to see if I can contribute or be any help on that, and yes, for some reason gradio on mozilla firefox looks so nice including multiple functionalities like downloading the audio, in chrome is similar but you download the audio in a weird format that you can only reproduce using VLC

@Alanp777
Copy link

Alanp777 commented May 7, 2023

@abidlabs also I dont mean to piggyback this but is there any way to speed up the audio? Ive been trying to do some code and research all options but for some reason gradio doesnt interpret all of the 6 strategies i used, I will keep looking around, and actually I provided the other day the documentation about being able to download audio from browsers, so im not only trying to extract value, will try to do my best to add and contribute more to the community, THANKS so much!

@drscotthawley
Copy link
Author

@Alanp777 Not sure what you mean: I have no problem playing back in iOS.
Either using numpy arrays or filepath, works fine. (I recommend filepath as it seems to be more versatile, e.g. works with gr.Examples.)

@Alanp777
Copy link

Alanp777 commented May 7, 2023

@Alanp777 no it doesnt work, try it yourself https://huggingface.co/spaces/WXM2000/audio_to_text_Chinese

or any other space, try to playback the audio on Safari browser, also my users complain about the same

@drscotthawley
Copy link
Author

drscotthawley commented May 7, 2023 via email

@Alanp777
Copy link

Alanp777 commented May 7, 2023

@drscotthawley my apologies, I should have specified, Safari Browser on DESKTOP, not iOS, my mistake.

@drscotthawley
Copy link
Author

@Alanp777 No, that works fine for me too. Just tried it. On my Mac. In Safari. ✅

Is perhaps your default audio device assigned incorrectly in System Preferences?

@drscotthawley
Copy link
Author

Confirming that iOS audio uploads now work in PyPI gradio==3.29.0. Thanks! :-)

@abidlabs
Copy link
Member

Great, thanks for confirming @drscotthawley!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants