Voice Capture
1. Introductionβ
Voice capture is performed with the Voice Component.
This component handles capturing the userβs voice and extracting the corresponding templates. Its main processes include:
- Internal microphone and permission management.
- Prompting a series of phrases for the user to read.
- Silence detection analysis.
- Progress tracking during capture.
- Guided assistance throughout the capture process.
- Generation of voice templates and quality scores.
Refer to the Quickstart section for basic SDK integration. This section provides details for launching this component.
2. Dependencyβ
Add the component-specific dependency:
implementation "com.facephi.androidsdk:voice_component:$version"
3. Available Controllersβ
| Controller | Description |
|---|---|
| VoiceController | Main controller for voice capture |
4. Quick Launchβ
Once the SDK is initialized and a new operation has been created, launch the component:
val response = SDKController.launch(
VoiceController(
VoiceConfigurationData(
phrases = arrayOf(
"Your full name and address",
"Your document number with letter"
)
)
)
)
when (response) {
is SdkResult.Error -> Napier.d("VOICE: ERROR - ${response.error.name}")
is SdkResult.Success -> response.data
}
5. Basic Configurationβ
Create a VoiceConfigurationData object with the following field:
VoiceConfigurationData(
phrases = arrayOf(
"Your full name and address",
"Your document number with letter"
)
)
You can customize the list of phrases to be presented to the user.
6. Receiving the Resultβ
The launch returns an SdkResult. Handle success and error:
when (response) {
is SdkResult.Error -> Napier.d("VOICE: ERROR - ${response.error}")
is SdkResult.Success -> response.data
}
6.1 Handling Errorsβ
Errors are returned as a VoiceError object. Possible values include:
- VOC_ACTIVITY_RESULT_MSG_ERROR: The result of the activity is incorrect.
- VOC_APPLICATION_CONTEXT_ERROR: Required application context is null.
- VOC_CANCEL_BY_USER: User has cancelled the process.
- VOC_CANCEL_LAUNCH: A general cancellation of the SDK has been done.
- VOC_COMPONENT_LICENSE_ERROR: The license of the component is not correct.
- VOC_EMPTY_LICENSE: License String is empty.
- VOC_FETCH_DATA_ERROR: Error in the result collection.
- VOC_FLOW_ERROR: Error in the flow process.
- VOC_INITIALIZATION_ERROR: Initialisation error.
- VOC_INTERNAL_LICENSE_ERROR: Internal error related to the component license
- VOC_MANAGER_NOT_INITIALIZED: Managers are nil.
- VOC_NO_DATA_ERROR: Input data is null.
- VOC_OPERATION_NOT_CREATED: No operation in progress.
- VOC_PERMISSION_DENIED: User has denied permissions.
- VOC_TIMEOUT: Timeout in the process.
6.2 Handling Success β dataβ
On success (SdkResult.Success), you receive a VoiceResult object. It contains: