> 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

This component requires iOS 13 or later.

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

The *Component* covered in this document is called ***Voice Component***. It is responsible for capturing the user's voice and then extracting the corresponding templates. Its main features are as follows:

* Entering a number of phrases, which the user then reads one at a time.
* Internal microphone management.
* Permission management.
* Silence analysis.
* Progress analysis.
* Assistance during the capture process.
* Generating templates with voice characteristics and scores.

The [Simplified Launch](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/ios-sdk/inicializacion/lanzamiento-simplificado.md) section describes the steps required for basic SDK integration. This section provides information about launching this component.

## **Dependencies**

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

### CocoaPods

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

* To install this component, add the following entry to the application's Podfile:

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

* Once the dependencies are installed, you can use the component's various features.

### **SPM**

* The required dependencies that must be installed beforehand 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, add the following to 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, the following item must be added to the **Info.plist**:

```
Microphone access must be allowed (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 this component, create a *VoiceConfigurationData* object, which will configure the component's controller.

The basic configuration required is as follows:

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

You can edit the list of phrases that will be shown to the user.

## Receiving the result <a href="#id-7-recepcion-del-resultado" id="id-7-recepcion-del-resultado"></a>

The controllers return the required information in SdkResult format.

### Receiving errors <a href="#id-71-recepcion-de-errores" id="id-71-recepcion-de-errores"></a>

For errors, the common enumeration *ErrorType*:

* VOC\_CANCEL\_BY\_USER: The user canceled the process
* VOC\_CANCEL\_LAUNCH: The SDK was canceled globally
* VOC\_COMPONENT\_LICENSE\_ERROR: The component license is invalid
* 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: No operation is in progress
* VOC\_PERMISSION\_DENIED: The user denied permissions
* VOC\_TIMEOUT: Process timeout

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

For *data*, we have the *VoiceResult*.

class. The *data* field is variable and depends on which component returned the result. For this component, the returned fields are as follows:

**audios**

Contains a list of audio recordings captured in ByteArray format.

**tokenizedAudios**

Contains the list of audio recordings captured in Facephi's tokenized format.

## Advanced information

This section provides additional information about the component.

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

To configure the current component, after it has been initialized, create a

*VoiceConfigurationData* object and pass it as a parameter to SDKController when launching the component.

The following section describes the fields in this class and what each one is used for.

**phrases**

Specifies the phrase or phrases required for capture.

**vibrationEnabled**

Specifies whether vibration is enabled when the widget completes successfully.

**showTutorial**

Specifies whether the component displays the tutorial screen. This view intuitively explains how to capture the document.

**extractionTimeout**

Sets the maximum capture duration.

**showDiagnostic**

Show diagnostic screens at the end of the process

**enableQualityCheck**

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

**showPreviousTip**

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

## Customization of the component

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

### Text

The text can be customized by overriding the values of the following keys in a **Localizable.strings**. Keys with the suffix ***\_alt*** are the strings used for the accessibility labels required for ***VoiceOver***.

| **Name**                                               | **Value**                                                                |
| ------------------------------------------------------ | ------------------------------------------------------------------------ |
| voice\_component\_success\_records\_message            | %d/%d successful recordings                                              |
| voice\_component\_read\_message                        | Say aloud:                                                               |
| voice\_component\_speech\_message                      | Speak clearly and close to the microphone                                |
| voice\_component\_speech\_noisy\_message               | There is too much background noise. Try to find a quiet place.           |
| voice\_component\_success\_message                     | Recording captured                                                       |
| voice\_component\_phrase\_generic\_error\_message      | Please repeat the phrase.                                                |
| voice\_component\_phrase\_long\_silence\_message       | Speak for 2 seconds or longer.                                           |
| voice\_component\_phrase\_long\_reverberation\_message | Too much echo. Try another place.                                        |
| voice\_component\_tip\_title                           | Speech recognition                                                       |
| voice\_component\_tip\_message                         | Speak clearly and loudly.\n\nMake sure you are in a quiet place          |
| 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 place |
| voice\_component\_short\_recorded\_speech\_message     | The recording was too 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                                                                  |
| voice\_component\_timeout\_desc                        | We couldn't identify you. Please try again.                              |

This way, if you want to change, for example, the text “*START*” for the key `voice_component_tip_button_message` for the language **es**, go to the file **Localizable.strings** in the **es.lproj** folder, if it exists (otherwise, create it), and add:

```xml
"voice_component_success_records_message" = "%d/%d successful recordings";
"voice_component_read_message" = "Read aloud:";
"voice_component_speech_message" = "Speak clearly and close to the microphone";
"voice_component_speech_noisy_message" = "There's too much background noise. Try to find 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 a different environment.";
"voice_component_tip_title" = "Voice recognition";
"voice_component_tip_message" = "Speak clearly and loudly.\n\nMake sure you're 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're in a quiet environment";
"voice_component_short_recorded_speech_message" = "The recording was too 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 a phone in front of their face and speaking directly to it. Before starting, if you use a screen reader, use headphones.";
"voice_component_timeout_title"="Timeout";
"voice_component_timeout_desc"="We couldn't identify you. Please try again.";

```

If a message isn't specified in the language file, it will be populated 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, whose value is a string containing the name of the animation 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
```
