# Setup Voice Verification

#### Uploading Api details to matches enrolled user's audio files with target user's audio file

```
try {
    const formData = new FormData();

    // Append first enroll recording in wav format
    const enroll1Path = `${RNFS.DocumentDirectoryPath}/${username}_0.wav`;
    const exists1 = await RNFS.exists(enroll1Path);
    if (!exists1) {
      throw new Error(`Enroll recording 0 not found at ${enroll1Path}`);
    }

    formData.append('sourceone', {
      uri: Platform.OS === 'android' ? `file://${enroll1Path}` : enroll1Path,
      type: 'audio/wav',
      name: 'sourceone.wav',
    });

    // Append second enroll recording in wav format
    const enroll2Path = `${RNFS.DocumentDirectoryPath}/${username}_1.wav`;
    const exists2 = await RNFS.exists(enroll2Path);
    if (!exists2) {
      throw new Error(`Enroll recording 1 not found at ${enroll2Path}`);
    }
    formData.append('sourcetwo', {
      uri: Platform.OS === 'android' ? `file://${enroll2Path}` : enroll2Path,
      type: 'audio/wav',
      name: 'sourcetwo.wav',
    });

    // Append third enroll recording in wav format
    const enroll3Path = `${RNFS.DocumentDirectoryPath}/${username}_2.wav`;
    const exists3 = await RNFS.exists(enroll3Path);
    if (!exists3) {
      throw new Error(`Enroll recording 2 not found at ${enroll3Path}`);
    }
    formData.append('sourcethree', {
      uri: Platform.OS === 'android' ? `file://${enroll3Path}` : enroll3Path,
      type: 'audio/wav',
      name: 'sourcethree.wav',
    });

    // Append verify recording in wav format
    if (!verifyFilePath) {
      throw new Error('Verification file path not provided');
    }
    const verifyExists = await RNFS.exists(verifyFilePath);
    if (!verifyExists) {
      throw new Error(`Verification file not found at ${verifyFilePath}`);
    }
    formData.append('target', {
      uri: Platform.OS === 'android' ? `file://${verifyFilePath}` : verifyFilePath,
      type: 'audio/wav',
      name: 'target.wav',
    });

    // Send the FormData payload.
    const response = await fetch('Your API', {
      method: 'POST',
      body: formData,
      // Let fetch set the Content-Type header automatically.
    });
    if (response.status === 200) {
      const responseBody = await response.text();
      console.log(responseBody);
      const parsedResponse = JSON.parse(responseBody);
      const score = parsedResponse.score;
      Alert.alert('Matching Score', score);
    } else {
      throw new Error(`Upload failed with status ${response.status}`);
    }
  } catch (error) {
    Alert.alert('Error during upload', error.message);
  }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.accurascan.com/solutions/voice-biometrics/react-native/setup-voice-verification.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
