Add vad clear api for better performance (#366)
* Add vad clear api for better performance * rename to make naming consistent and remove macro * Fix linker error * Fix Vad.kt
This commit is contained in:
@@ -161,9 +161,9 @@ class MainActivity : AppCompatActivity() {
|
||||
val samples = FloatArray(ret) { buffer[it] / 32768.0f }
|
||||
|
||||
vad.acceptWaveform(samples)
|
||||
while(!vad.empty()) {vad.pop();}
|
||||
|
||||
val isSpeechDetected = vad.isSpeechDetected()
|
||||
vad.clear()
|
||||
|
||||
runOnUiThread {
|
||||
onVad(isSpeechDetected)
|
||||
|
||||
@@ -46,6 +46,8 @@ class Vad(
|
||||
// [start: Int, samples: FloatArray]
|
||||
fun front() = front(ptr)
|
||||
|
||||
fun clear() = clear(ptr)
|
||||
|
||||
fun isSpeechDetected(): Boolean = isSpeechDetected(ptr)
|
||||
|
||||
fun reset() = reset(ptr)
|
||||
@@ -64,6 +66,7 @@ class Vad(
|
||||
private external fun acceptWaveform(ptr: Long, samples: FloatArray)
|
||||
private external fun empty(ptr: Long): Boolean
|
||||
private external fun pop(ptr: Long)
|
||||
private external fun clear(ptr: Long)
|
||||
private external fun front(ptr: Long): Array<Any>
|
||||
private external fun isSpeechDetected(ptr: Long): Boolean
|
||||
private external fun reset(ptr: Long)
|
||||
|
||||
Reference in New Issue
Block a user