> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/ios-sdk/modulos/captura-de-voz.md).

# Voice Capture - VoiceID

## Introduction <a href="#id-1-introduccion" id="id-1-introduccion"></a>

The *Component* the one addressed in the current document is called ***Voice Component***. This is responsible for capturing the user's voice and then extracting the corresponding templates. Its main functionalities are the following:

* Input of a certain number of phrases to later read each one in a step.
* Internal microphone management.
* Permission management.
* Analysis of silences.
* Progress analysis.
* Assistant in the capture processes.
* Generation of templates with voice features and scores.

In the section of [Simplified Launch](/docs.facephi-en/sdks/sdk-mobile/ios-sdk/inicializacion/lanzamiento-simplificado.md) the necessary steps for the basic integration of the SDK are detailed. In this section, information is added for the launch of this component.

## **Dependencies**

To avoid conflicts and compatibility issues, if you want to install the component in a project that contains an old version of the Facephi libraries (*Widgets*), they must be completely removed before installing the components of the **SDKMobile**.

### CocoaPods

```sh
pod 'FPHISDKMainComponent', '~> $VERSION'
```

* To install the current component, the following entry must be included in the application's Podfile:

```sh
pod 'FPHISDKVoiceIDComponent', '~> $VERSION'
```

* Once the dependencies are installed, the different functionalities of the component can be used.

### **SPM**

* The mandatory dependencies that must have been installed previously are:

```swift
//HTTPS
https://github.com/facephi-clienters/SDK-SdkPackage-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-SdkPackage-SPM.git
```

* To install the Selphid component, it must be included in the project's modules:

<pre class="language-swift"><code class="lang-swift"><strong>//HTTPS
</strong>https://github.com/facephi-clienters/SDK-VoicePackage-SPM.git
//SSH
git@github.com:facephi-clienters/SDK-VoicePackage-SPM.git
</code></pre>

## Permissions

In the client application where the components will be integrated, it is necessary to include the following element in the file **Info.plist**:

```
It is necessary to allow the use of the microphone (NSMicrophoneUsageDescription - Privacy - Microphone Usage Description)
```

## Available controllers <a href="#id-4-controladores-disponibles" id="id-4-controladores-disponibles"></a>

| **Controller**  | **Description**               |
| --------------- | ----------------------------- |
| VoiceController | Main voice capture controller |

## Simplified Launch

```swift
let controller = VoiceController(data: voiceConfigurationData, output: { sdkResult in
        // Do whatever with the result
        ...
    }, viewController: viewController)
SDKController.shared.launch(controller: controller)
```

## Basic configuration

To launch the current component, an object *VoiceConfigurationData* must be created, which will be the configuration of the component controller.

The basic configuration needed for this is as follows:

```swift
static var voiceIDConfiguration: VoiceConfigurationData {
    let configVoiceID = VoiceConfigurationData(
            phrases: ["Your full name and your address",
                      "Your document number with letter"])
    return configVoiceID
}
```

The list of phrases that will be shown to the user can be edited.

## Result reception <a href="#id-7-recepcion-del-resultado" id="id-7-recepcion-del-resultado"></a>

The controllers will return the necessary information in SdkResult format.

### Error handling <a href="#id-71-recepcion-de-errores" id="id-71-recepcion-de-errores"></a>

In the error section, we will have the common enum *ErrorType*:

* VOC\_CANCEL\_BY\_USER: The user has canceled the process
* VOC\_CANCEL\_LAUNCH: A general SDK cancellation has been performed
* VOC\_COMPONENT\_LICENSE\_ERROR: The component license is not correct
* VOC\_EMPTY\_LICENSE: The license String is empty
* VOC\_INITIALIZATION\_ERROR: Initialization error
* VOC\_INTERNAL\_LICENSE\_ERROR: Internal error related to the license
* VOC\_NO\_DATA\_ERROR: The input data are null
* VOC\_OPERATION\_NOT\_CREATED: There is no operation in progress
* VOC\_PERMISSION\_DENIED: The user has denied the permissions
* VOC\_TIMEOUT: Timeout during the process

### Successful execution receipt - *data* <a href="#id-72-recepcion-de-ejecucion-correcta-data" id="id-72-recepcion-de-ejecucion-correcta-data"></a>

In the *data*, we will have the class *VoiceResult*.

The field *data* is variable and will depend on which component returned the result. In the case of this component, the returned fields are as follows:

**audio files**

Contains a list of captured audio recordings in ByteArray format.

**tokenizedAudios**

Contains the list of captured audio recordings in Facephi Tokenized format.

## Advanced information

This section expands on the component information.

### Advanced component configuration <a href="#id-5-configuracion-del-componente" id="id-5-configuracion-del-componente"></a>

To configure the current component, once initialized, an object must be created

*VoiceConfigurationData* and pass it as a parameter to SDKController during the component launch.

The following section will show the fields that are part of this class and what each one is used for.

**phrases**

Indicates the phrase or phrases needed for capture.

**vibrationEnabled**

Indicates whether vibration is activated when the Widget successfully finishes.

**showTutorial**

Indicates whether the component activates the tutorial screen. In this view, it intuitively explains how the capture is performed.

**extractionTimeout**

Sets the maximum time that capture can be performed.

**showDiagnostic**

Show diagnostic screens at the end of the process

**enableQualityCheck**

Enables or disables audio quality checking. It is recommended to always keep it enabled.

**showPreviousTip**

Displays a screen before starting the capture with information about the process to be carried out and a button to start it.

## Component Customization

Besides the changes that can be made at SDK level (which are explained in the document of *SDK Customization*), this specific component allows its interface to be modified.

### Texts

The texts can be customized by overriding the value of the following keys in a **Localizable.strings**. The keys containing the suffix ***\_alt*** are the literals used in the accessibility labels needed for the functionality of ***voice over***.

| **Name**                                               | **Value**                                                                      |
| ------------------------------------------------------ | ------------------------------------------------------------------------------ |
| voice\_component\_success\_records\_message            | %d/%d successful recordings                                                    |
| voice\_component\_read\_message                        | Say out loud:                                                                  |
| voice\_component\_speech\_message                      | Speak clearly and close to the microphone                                      |
| voice\_component\_speech\_noisy\_message               | There is too much noise. Try to be in a quiet environment.                     |
| voice\_component\_success\_message                     | Recording saved                                                                |
| voice\_component\_phrase\_generic\_error\_message      | Please repeat the phrase.                                                      |
| voice\_component\_phrase\_long\_silence\_message       | Speak for 2 seconds or more.                                                   |
| voice\_component\_phrase\_long\_reverberation\_message | Too much echo. Try another environment.                                        |
| voice\_component\_tip\_title                           | Voice recognition                                                              |
| voice\_component\_tip\_message                         | Speak clearly and loudly.\n\nMake sure you are in a quiet environment          |
| voice\_component\_tip\_button                          | START                                                                          |
| voice\_component\_exit\_alert\_accept                  | Accept                                                                         |
| voice\_component\_exit\_alert\_cancel                  | Cancel                                                                         |
| voice\_component\_exit\_alert\_question                | Are you sure you want to end the process?                                      |
| voice\_component\_multiple\_speakers\_error\_message   | Background voices have been detected. Make sure you are in a quiet environment |
| voice\_component\_short\_recorded\_speech\_message     | The recording has been very short.                                             |
| voice\_component\_quality\_check\_error\_message       | The audio quality is insufficient.                                             |
| voice\_component\_close\_button\_alt                   | Close                                                                          |
| voice\_component\_logo\_alt                            | Logo                                                                           |
| voice\_component\_tip\_anim\_alt                       |                                                                                |
| voice\_component\_timeout\_title                       | Timeout exceeded                                                               |
| voice\_component\_timeout\_desc                        | We have not been able to identify you. Try again.                              |

In this way, if you want to modify, for example, the text “*START*” of the key `voice_component_tip_button_message` for the language **is**, you will have to go to the file **Localizable.strings** in the folder **es.lproj** if it exists (if not, it must be created) and there, add:

```xml
"voice_component_success_records_message" = "%d/%d successful recordings";
"voice_component_read_message" = "Say out loud:";
"voice_component_speech_message" = "Speak clearly and close to the microphone";
"voice_component_speech_noisy_message" = "There is too much noise. Try to be in a quiet environment.";
"voice_component_success_message" = "Recording saved";
"voice_component_phrase_generic_error_message" = "Please repeat the phrase.";
"voice_component_phrase_long_silence_message" = "Speak for 2 seconds or more.";
"voice_component_phrase_long_reverberation_message" = "Too much echo. Try another environment.";
"voice_component_tip_title" = "Voice recognition";
"voice_component_tip_message" = "Speak clearly and loudly.\n\nMake sure you are in a quiet environment";
"voice_component_tip_button" = "START";
"voice_component_exit_alert_accept"="Accept";
"voice_component_exit_alert_cancel"="Cancel";
"voice_component_exit_alert_question" = "Are you sure you want to end the process?";
"voice_component_multiple_speakers_error_message" = "Background voices have been detected. Make sure you are in a quiet environment";
"voice_component_short_recorded_speech_message" = "The recording has been very short.";
"voice_component_quality_check_error_message" = "The audio quality is insufficient.";
"voice_component_close_button_alt" = "Close";
"voice_component_logo_alt" = "Logo";
"voice_component_tip_anim_alt"="Animation showing a person holding the phone in front of their face and speaking directly to it. Before you begin, if you use a screen reader, use headphones.";
"voice_component_timeout_title"="Time exceeded";
"voice_component_timeout_desc"="We have not been able to identify you. Try again.";

```

If a message is not specified in the language file, it will be filled with the default message.

### Animations <a href="#id-84-animaciones" id="id-84-animaciones"></a>

The animations to use are initialized similarly in the animations variable with a dictionary, having as value a string with the name of the animation found in xcassets that you want to use.

```
case voice_anim_enroll
case voice_anim_enroll_error
case voice_anim_enroll_ok
case voice_anim_intro
```
