Last active
December 8, 2020 04:07
-
-
Save farmaker47/1f02ca978a3704c2854aec608157686d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun execute(floatsInput: FloatArray): Pair<ArrayList<String>, ArrayList<Float>> { | |
predictTime = System.currentTimeMillis() | |
val inputSize = floatsInput.size // ~2 seconds of sound | |
//Log.i("YAMNET_INPUT_SIZE", inputSize.toString()) | |
val inputValues = floatsInput//FloatArray(inputSize) | |
val inputs = arrayOf<Any>(inputValues) | |
val outputs = HashMap<Int, Any>() | |
// Outputs of yamnet model with tflite and for 2 seconds .wav file | |
// scores(4, 521) emmbedings(4, 1024) spectogram(240, 64) | |
val arrayScores = Array(4) { FloatArray(521) { 0f } } | |
val arrayEmbeddings = Array(4) { FloatArray(1024) { 0f } } | |
val arraySpectograms = Array(240) { FloatArray(64) { 0f } } | |
outputs[0] = arrayScores | |
outputs[1] = arrayEmbeddings | |
outputs[2] = arraySpectograms | |
try { | |
interpreter.runForMultipleInputsOutputs(inputs, outputs) | |
} catch (e: Exception) { | |
Log.e("EXCEPTION", e.toString()) | |
} | |
.............................. | |
.............................. | |
return Pair(finalListOfOutputs, listOfMaximumValues) // ArrayList<String> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment