alphacep / vosk-api

Offline speech recognition API for Android, iOS, Raspberry Pi and servers with Python, Java, C# and Node
Apache License 2.0
7.35k stars 1.04k forks source link

Can't Access "recorder" AudioRecord object within SpeechService on Android to add noise suppression #1583

Open andreystarenky opened 1 month ago

andreystarenky commented 1 month ago

I am looking to use the native Android NoiseSuppressor class which works by providing it with the Session ID from the native AudioRecord object which SpeechService (Vosk Android Java class) uses. It is accessed by calling [AudioRecord.getAudioSessionId()](https://developer.android.com/reference/android/media/AudioRecord#getAudioSessionId()) on the AudioRecord object, but the object is a private variable in the SpeechService class and there is no getter method for it.

Thanks

nshmyrev commented 3 weeks ago

You are welcome to submit a patch to add getter

tuan-jason commented 3 weeks ago

I am looking to use the native Android NoiseSuppressor class which works by providing it with the Session ID from the native AudioRecord object which SpeechService (Vosk Android Java class) uses. It is accessed by calling [AudioRecord.getAudioSessionId()](https://developer.android.com/reference/android/media/AudioRecord#getAudioSessionId()) on the AudioRecord object, but the object is a private variable in the SpeechService class and there is no getter method for it.

Thanks

@andreystarenky Use reflection in the mean time while it's not yet supported by the community.