Skip to content

Pause Detection #2

Description

@brandall76

Hi Kaarel, I needed a solution for pause detection in my app and your solution is the best one I've found. Good work and thanks for sharing. I've abstracted it so it's easier to include anywhere.

The issue is with the MediaRecorder.AudioSource type and how differently it behaves between MIC and VOICE_RECOGNITION and across various devices. I've added a PAUSE_IGNORE_TIME to prevent the immediate reports of pause scores > 100 being triggered, until the results appear to settle down to below PAUSE_THRESHOLD = 7.

Not sure if the threading and synchronisation is a little too much, but seems to work fine.

Hope constructing it as a separate entity will help perfect it.

I've also added my standard logging class, as I couldn't be bothered to remove it all from my code :)

Gist of Classes here

Ben

Activity

brandall76 commented on Feb 19, 2016

@brandall76
Author

Edited the gist - line 125 on PauseDetector - detection should have been wrapped in else {}

Kaljurand commented on Feb 20, 2016

@Kaljurand
Owner

Thanks Ben! I'll try to integrate your contribution at some point. (You're also welcome to offer it as a pull request.)

I never tested my pause detection with different audio sources nor with many different devices. I know that it has problems with background noise. So, I've viewed it as a temporary solution that will have to be replaced with something more serious in the future. (Possibly Android itself would offer a builtin solution at some point.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions