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:
yujinqiu
2023-10-16 14:40:47 +08:00
committed by GitHub
parent 55b6893885
commit d01682d968
9 changed files with 55 additions and 25 deletions

View File

@@ -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)

View File

@@ -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)