Skip to content

[Android] Speech recognition example #236

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
May 17, 2023
Merged

Conversation

edgchen1
Copy link
Contributor

@edgchen1 edgchen1 commented May 9, 2023

Add speech recognition example for Android using Whisper model.

Thanks @MaanavD for help with the UI.

@edgchen1 edgchen1 requested a review from natke May 9, 2023 17:24
@edgchen1 edgchen1 marked this pull request as ready for review May 15, 2023 19:27
@edgchen1 edgchen1 changed the title [WIP][Android] Whisper example [Android] Speech recognition example May 15, 2023
Copy link
Contributor

@YUNQIUGUO YUNQIUGUO left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Great example:)


// Disable audio buttons first.
// The stop button will be enabled by the recording task.
disableAudioButtons()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering why do we need this "disable" state handling of the audio button?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since pressing this button starts some work in another thread, I didn't want to allow it to be pressed again before the recording is done and have to worry about keeping state consistent.

return OnnxTensor.createTensor(env, FloatBuffer.wrap(data), shape)
}

internal fun tensorShape(vararg dims: Long) = longArrayOf(*dims)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know there's a vararg keyword in kotlin.

assuming it is safe to pass in zero elements and also only works for the same type series of arguments?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edgchen1 edgchen1 merged commit e736b13 into main May 17, 2023
@edgchen1 edgchen1 deleted the edgchen1/whisper_android branch May 17, 2023 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants