> 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 handled in the current document is called ***Voice Component***. This is responsible for capturing the user's voice and subsequently extracting the corresponding templates. Its main functionalities are the following:

* Enter a certain number of phrases and then read each one in a step.
* Internal microphone management.
* Permission management.
* Silence analysis.
* Progress analysis.
* Assistant in the capture processes.
* Generation of templates with voice characteristics and scores.

In the section of [Simplified Launch](/docs.facephi-en/sdks/sdk-mobile/ios-sdk/inicializacion/lanzamiento-simplificado.md) the steps required for the SDK's basic integration are detailed. This section adds the information for launching 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*), these 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 previously installed 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 **Info.plist**:

```
It is necessary to allow microphone usage (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 must be created *VoiceConfigurationData* which will be the configuration of the component controller.

The basic configuration required 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 to be shown to the user can be edited.

## Receiving the result <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 enumeration *ErrorType*:

* VOC\_CANCEL\_BY\_USER: The user has cancelled the process
* VOC\_CANCEL\_LAUNCH: A general cancellation of the SDK has been carried out
* VOC\_COMPONENT\_LICENSE\_ERROR: The component license is not valid
* VOC\_EMPTY\_LICENSE: The license string is empty
* VOC\_INITIALIZATION\_ERROR: Initialization error
* VOC\_INTERNAL\_LICENSE\_ERROR: Internal license-related error
* VOC\_NO\_DATA\_ERROR: The input data is null
* VOC\_OPERATION\_NOT\_CREATED: There is no operation in progress
* VOC\_PERMISSION\_DENIED: The user has denied the permissions
* VOC\_TIMEOUT: Timeout in the process

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

In the section of *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:

**audios**

Contains a list of captured audios in ByteArray format.

**tokenizedAudios**

Contains the list of captured audios 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 passed as a parameter to SDKController during the component launch.

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

**phrases**

Indicates the phrase/phrases needed to capture.

**vibrationEnabled**

Indicates whether vibration is activated when the Widget finishes successfully.

**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 allowed for the capture.

**showDiagnostic**

Show diagnostic screens at the end of the process

**enableQualityCheck**

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

**showPreviousTip**

Shows a screen before capture launch with information about the process to be performed and a launch button.

## Component customization

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

### Texts

The texts can be customized by overwriting 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 registered                                                  |
| 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?                             |
| Background voices have been detected. Make sure you are in a quiet environment | The recording has been very short.                                    |
| 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                                               | Time exceeded                                                         |
| voice\_component\_timeout\_desc                                                | We could not identify you. Try again.                                 |

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 should 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 registered";
"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 finish 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 in which a person appears holding the phone in front of their face and speaking directly into it. Before starting, if you use a screen reader, use headphones.";
"voice_component_timeout_title"="Time exceeded";
"voice_component_timeout_desc"="We could not 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
```
