Move finishing transcription to recording thread
This commit is contained in:
Родитель
5ac4e6b0cb
Коммит
0d3c1ac52a
|
@ -22,7 +22,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
// Change the following parameters regarding
|
||||
// what works best for your use case or your language.
|
||||
private val BEAM_WIDTH = 500
|
||||
private val BEAM_WIDTH = 500L
|
||||
private val LM_ALPHA = 0.931289039105002f
|
||||
private val LM_BETA = 1.1834137581510284f
|
||||
|
||||
|
@ -40,8 +40,7 @@ class MainActivity : AppCompatActivity() {
|
|||
|
||||
private fun checkAudioPermission() {
|
||||
// permission is automatically granted on sdk < 23 upon installation
|
||||
if (Build.VERSION.SDK_INT >= 23)
|
||||
{
|
||||
if (Build.VERSION.SDK_INT >= 23) {
|
||||
val permission = Manifest.permission.RECORD_AUDIO
|
||||
|
||||
if (checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) {
|
||||
|
@ -63,6 +62,9 @@ class MainActivity : AppCompatActivity() {
|
|||
val decoded = model?.intermediateDecode(streamContext)
|
||||
runOnUiThread { transcription.text = decoded }
|
||||
}
|
||||
val decoded = model?.finishStream(streamContext)
|
||||
runOnUiThread { transcription.text = decoded }
|
||||
recorder?.stop()
|
||||
}
|
||||
|
||||
private fun createModel(): Boolean {
|
||||
|
@ -134,11 +136,6 @@ class MainActivity : AppCompatActivity() {
|
|||
private fun stopListening() {
|
||||
isRecording = false
|
||||
btnStartInference.text = "Start Recording"
|
||||
|
||||
val decoded = model?.finishStream(streamContext)
|
||||
transcription.text = decoded
|
||||
|
||||
recorder?.stop()
|
||||
}
|
||||
|
||||
fun onRecordClick(v: View?) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче