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

Feature Request - Work with Audio file's download URL #101

Open
prakhart111 opened this issue Aug 27, 2023 · 6 comments
Open

Feature Request - Work with Audio file's download URL #101

prakhart111 opened this issue Aug 27, 2023 · 6 comments

Comments

@prakhart111
Copy link

I recently used Parselmouth, but my deployment server was read-only (Vercel) so I can't save the audio file that was coming from the client.

This can be resolved if Parselmouth supports fetching the file directly via a cloud URL (like aws).
I would love to help if someone's building this, or decides to build after this request.

Thanks.

@YannickJadoul
Copy link
Owner

Hi, @prakhart111! I'm a bit hesitant to add any sort of networking to Parselmouth, as it somewhat diverges from the available Praat functionality.

But, with a couple of lines, you can already do this via a detour. Based on one of PySoundfile's examples in the documentation:

import io
import parselmouth
import soundfile as sf
from urllib.request import urlopen

def read_parselmouth_sound_from_url(url):
    data, samplerate = sf.read(io.BytesIO(urlopen(url).read()), dtype='float64')
    return parselmouth.Sound(data, sampling_frequency=samplerate)

read_parselmouth_sound_from_url("https://parselmouth.readthedocs.io/en/latest/examples/audio/the_north_wind_and_the_sun.wav")

Would this work for you?

Based on this, I would be curious to try reading a BytesIO into a parselmouth.Sound, though. This would remove the need to use an extra library like soundfile, and the networking part would still be outside of Parselmouth. After all, the whole point of Parselmouth is to be able to combine Praat with all other Python libraries.
What do you think of this? Does it seem like an acceptable solution?

@prakhart111
Copy link
Author

prakhart111 commented Aug 27, 2023

Hey @YannickJadoul ,
That's a pretty good solution. About BytesIO readability, we can add it, Ping me when you do it, I'll be happy to help with whatever I can:)

Since most free deployment services are ReadOnly, this will help people using parselMouth. I deployed on PythonAnywhere, with help of a friend, and that worked for me.
This is what I built with your lib & openai API -> https://github.com/prakhart111/ToneCraft

Also, this soundfile thing should be added to the docs as well?

@YannickJadoul
Copy link
Owner

Hi @prakhart111. I had a closer look, and it seems possible, but will require quite some refactoring (potentially replacing the usage of Praat's FILE * by C++ streams).

But yes, I agree that integration with io.BytesIO would be a useful addition, so I will try to find time to work on this.

@prakhart111
Copy link
Author

prakhart111 commented Aug 31, 2023

Sure, ping me here if you need some help ;)
https://twitter.com/PrakharTandon29

For future readers, a quick solution will be deploying on pythonanywhere by setting up a virtual env.
You can find it here: https://help.pythonanywhere.com/pages/Virtualenvs/

@YannickJadoul
Copy link
Owner

I'm not on Twitter, I'm afraid ;-)
But do find me and other Parselmouth users on the Gitter, if you want to chat: https://app.gitter.im/#/room/#PraatParselmouth_Lobby:gitter.im (you can just log in with GitHub credentials)

If you want to have a stab at this, feel free to check out the code. I'll happily give you some pointers if you want.
But I'm well aware the whole combination of Python and C++ is rather intimidating, especially if you need to dive into the Praat part :-)

@prakhart111
Copy link
Author

Okay, I'll join you guys on gitter.

Yup, it is quite intimidating, especially for JS people ;) But I'll have a look for sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants