breizhn / DTLN

Tensorflow 2.x implementation of the DTLN real time speech denoising model. With TF-lite, ONNX and real-time audio processing support.
MIT License
585 stars 161 forks source link

TFLite Android #50

Open zeynepgulhanuslu opened 2 years ago

zeynepgulhanuslu commented 2 years ago

Hi, I want to use tflite model in android project. When I load model to android studio it generates a code like below:

` val model = Dtln.newInstance(context)

// Creates inputs for reference. val inputFeature0 = TensorBuffer.createFixedSize(intArrayOf(1, 1, 512), DataType.FLOAT32) inputFeature0.loadBuffer(byteBuffer) val inputFeature1 = TensorBuffer.createFixedSize(intArrayOf(1, 2, 128, 2), DataType.FLOAT32) inputFeature1.loadBuffer(byteBuffer)

// Runs model inference and gets result. val outputs = model.process(inputFeature0, inputFeature1) val outputFeature0 = outputs.outputFeature0AsTensorBuffer val outputFeature1 = outputs.outputFeature1AsTensorBuffer

// Releases model resources if no longer used. model.close() `

My question is what is the inputFeature0 and inputFeature1 in this code? Should I read wav file as byte array than reshape it? Or Should I create feature vector of wav file? Can you help me with this?

Thanks

ShivamSrivastavaAkaike commented 2 years ago

Hi , I also want to use this model on android , if you have used it on android then could you help?

zeynepgulhanuslu commented 2 years ago

Hi,

I used it but did not have a chance to use it as streaming. It only runs as a batch. If you want, I can send the code but it's a little messy since I didn't use it and didn't get the time to finish it properly. If you give me your mail, I can send it to you as a reference.

ShivamSrivastavaAkaike commented 2 years ago

yeah sure ,it will help. Thanks in advance here is my email id :- shivam@akaiketech.com

zeynepgulhanuslu commented 2 years ago

Okay I will send it to you, If you want you can delete the comment. I hope it helps, have a nice day.

mcig commented 1 year ago

Hello all 👋, I have also been trying to make this model work on android devices with kotlin. And unfortunately, same like you @zeynepgulhanuslu i got stuck while running the model inference from a recorded batch and with real time data. I have tried to reimplement the real_time_processing_tf_lite.py in kotlin but it got way too complicated to perform array operations and fft calculations without numpy.

Have you open sourced or uploaded your version anywhere? Honestly, it would help me a lot at this point 😅.

zeynepgulhanuslu commented 1 year ago

Hello Mustafa I didn't complete the code either. But I created a tflite model for fft calculations. You can find more information with searching "create a TFLite model from one or more concrete functions in TensorFlow." . This way you can do numpy operations in a tflite model. I hope this help.