asteroid-team / asteroid

The PyTorch-based audio source separation toolkit for researchers
https://asteroid-team.github.io/
MIT License
2.21k stars 419 forks source link

Support for mobile development (Android)? #690

Closed lxaw closed 5 months ago

lxaw commented 6 months ago

First, I'd like to thank everyone for their work here. This is great stuff.

Has anyone tried to download one of the pytorch models and run on Android? I am trying to make a speech separation application, using this model: https://zenodo.org/records/3873670

Following this, I was able to load the model into Android studio, but am having trouble understanding how to call separate on it.

In Python on my PC, I was able to successfully run the following:

from asteroid.models import BaseModel
import soundfile as sf

# 'from_pretrained' automatically uses the right model class (asteroid.models.DPRNNTasNet).
model = BaseModel.from_pretrained("mpariente/DPRNNTasNet-ks2_WHAM_sepclean")

# You can pass a NumPy array:
mixture, _ = sf.read("female-female-mixture.wav", dtype="float32", always_2d=True)
# Soundfile returns the mixture as shape (time, channels), and Asteroid expects (batch, channels, time)
mixture = mixture.transpose()
mixture = mixture.reshape(1, mixture.shape[0], mixture.shape[1])
out_wavs = model.separate(mixture)

# Or simply a file name:
model.separate("female-female-mixture.wav")

However, I cannot call 'separate' in Android.

Anyone ever tried to take a model and run on Android?

mpariente commented 6 months ago

Good question, but sorry, I did not !

lxaw commented 5 months ago

No worries! I'll see if I can get it working. Thanks!

MOKA-AITeam commented 1 month ago

Hi, how did you run on Android, how the effect is? @lxaw