Skip to content

How can I recude the delay between startListening() and requestbody()? #53

@skypiri

Description

@skypiri

When I pressed mic button to send audio data to alexa server, there is a delay about 1.5 sec.
I added two debug log message startListening() and reqeustbody() like below.
The real pcm audio data is sent to the server using sinkWrite().
But the first audio data is sent to the server after 1.5 sec when I pressed button.
The time gap between two debug messages is about 1.5 sec.
How can I reduce this delay?

I'll put the source code to show where I added log messages and adb log message to show timestamp.

@OverRide public void startListening() { Log.d(TAG, "start to alexa avs"); // Here is 1st message if(recorder == null){ recorder = new RawAudioRecorder(AUDIO_RATE); } recorder.start(); alexaManager.sendAudioRequest(requestBody, getRequestCallback()); }
private DataRequestBody requestBody = new DataRequestBody() {
    @Override
    public void writeTo(BufferedSink sink) throws IOException {

        Log.d(TAG, "requestBody is run....."); // Here is 2nd message
        while (recorder != null && !recorder.isPausing()) {
            if(recorder != null) {
                final float rmsdb = recorder.getRmsdb();
                if(recorderView != null) {
                    recorderView.post(new Runnable() {
                        @Override
                        public void run() {
                            recorderView.setRmsdbLevel(rmsdb);
                        }
                    });
                }
                if(sink != null && recorder != null) {
                    sink.write(recorder.consumeRecording());
                }
                if(BuildConfig.DEBUG){
                    Log.i(TAG, "Received audio");
                    Log.i(TAG, "RMSDB: " + rmsdb);
                }
            }

21:36:53.481, 21:36:54.722
12-07 21:36:53.481 15979-15979/com.willblaschko.android.alexavoicelibrary D/SendAudioActionFragment: start to alexa avs
12-07 21:36:53.482 15979-15979/com.willblaschko.android.alexavoicelibrary V/AudioRecord: set(): inputSource 6, sampleRate 16000, format 0x1, channelMask 0x10, frameCount 2560, notificationFrames 0, sessionId 0, transferType 0, flags 0
12-07 21:36:53.482 15979-15979/com.willblaschko.android.alexavoicelibrary V/AudioRecord: set(): mSessionId 14191
12-07 21:36:53.486 15979-15996/com.willblaschko.android.alexavoicelibrary V/AudioSystem: ioConfigChanged() event 3, ioHandle 14192
12-07 21:36:53.498 15979-15979/com.willblaschko.android.alexavoicelibrary V/AudioRecord: start, sync event 0 trigger session 0
12-07 21:36:53.498 15979-15979/com.willblaschko.android.alexavoicelibrary V/AudioRecord: mAudioRecord->start()
12-07 21:36:53.516 15979-17115/com.willblaschko.android.alexavoicelibrary I/BaseActivity: Event Start
12-07 21:36:53.518 15979-17115/com.willblaschko.android.alexavoicelibrary I/SpeechSendAudio: Starting SpeechSendAudio procedure
12-07 21:36:53.553 15979-17115/com.willblaschko.android.alexavoicelibrary D/libc-netbsd: [getaddrinfo]: hostname=avs-alexa-na.amazon.com; servname=(null); cache_mode=(null), netid=0; mark=0
12-07 21:36:53.553 15979-17115/com.willblaschko.android.alexavoicelibrary D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
12-07 21:36:53.554 15979-17115/com.willblaschko.android.alexavoicelibrary D/libc-netbsd: [getaddrinfo]: hostname=avs-alexa-na.amazon.com; servname=(null); cache_mode=(null), netid=0; mark=0
12-07 21:36:53.554 15979-17115/com.willblaschko.android.alexavoicelibrary D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=1024; ai_family=0
12-07 21:36:53.564 15979-17115/com.willblaschko.android.alexavoicelibrary I/System.out: propertyValue:false
12-07 21:36:53.588 15979-17115/com.willblaschko.android.alexavoicelibrary D/libc-netbsd: [getaddrinfo]: hostname=avs-alexa-na.amazon.com; servname=(null); cache_mode=(null), netid=0; mark=0
12-07 21:36:53.588 15979-17115/com.willblaschko.android.alexavoicelibrary D/libc-netbsd: [getaddrinfo]: ai_addrlen=0; ai_canonname=(null); ai_flags=4; ai_family=0
12-07 21:36:54.722 15979-17115/com.willblaschko.android.alexavoicelibrary D/SendAudioActionFragment: requestBody is run.....
12-07 21:36:54.728 15979-17115/com.willblaschko.android.alexavoicelibrary I/SendAudioActionFragment: Received audio

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions