Skip to content

Commit

Permalink
disable walkie-talkie mode
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Nov 8, 2024
1 parent b27ecff commit 662e0cd
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import kotlin.time.Duration.Companion.milliseconds
class SpeechRecognizerDictationService: DictationService, KoinComponent {
private val context: Context by inject()
private val scope = CoroutineScope(Dispatchers.IO)
/*
private val audioTrack = AudioTrack.Builder()
.setAudioFormat(AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
Expand All @@ -41,6 +42,7 @@ class SpeechRecognizerDictationService: DictationService, KoinComponent {
.setBufferSizeInBytes(16000)
.setTransferMode(AudioTrack.MODE_STREAM)
.build()
*/

companion object {
private val AUDIO_LATENCY = 600.milliseconds
Expand Down Expand Up @@ -141,7 +143,7 @@ class SpeechRecognizerDictationService: DictationService, KoinComponent {
emit(DictationServiceResponse.Error(Result.FailServiceUnavailable))
return@flow
}
audioTrack.play()
//audioTrack.play()

val audioJob = scope.launch {
audioStreamFrames
Expand All @@ -166,7 +168,7 @@ class SpeechRecognizerDictationService: DictationService, KoinComponent {
}
decodedBuf.rewind()
withContext(Dispatchers.IO) {
audioTrack.write(decodedBuf.array(), decodedBuf.arrayOffset(), decodeBufLength)
//audioTrack.write(decodedBuf.array(), decodedBuf.arrayOffset(), decodeBufLength)
recognizerWritePipe.write(decodedBuf.array(), decodedBuf.arrayOffset(), decodeBufLength)
}
}
Expand Down Expand Up @@ -212,7 +214,7 @@ class SpeechRecognizerDictationService: DictationService, KoinComponent {
}
}
} finally {
audioTrack.stop()
//audioTrack.stop()
audioJob.cancel()
speechRecognizer.destroy()
decoder.close()
Expand Down

0 comments on commit 662e0cd

Please sign in to comment.