Skip to content

Instantly share code, notes, and snippets.

@farmaker47
Last active December 8, 2020 04:07
Show Gist options
  • Save farmaker47/1f02ca978a3704c2854aec608157686d to your computer and use it in GitHub Desktop.
Save farmaker47/1f02ca978a3704c2854aec608157686d to your computer and use it in GitHub Desktop.
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