In this guide you will learn how to upload a media file as a voice sample to a space. This is a prerequisite to compute voiceprints or perform verifications.

If you are unfamiliar with these concepts, follow their links or read the API reference introduction.

✦ Goal: upload a voice sample and store its reference for future use.

Prerequisites

1

Set up your HTTP client

Use the playground or automatically generate requests from the OpenAPI definition.

2

Authenticate using your credentials or API keys

Your API requests must be authenticated using your credentials or API keys.

3

Gain access to a space

You can only operate in spaces that belong to your user or to one of your organizations. Review these relationships if your access is denied.

---> ownerspace

4

Obtain a valid media file

To upload a media file as a voice sample, it must meet the specified requirements.

---> file.mp3

Procedure

1

Encode the media file

You cannot directly upload the binary media file through the HTTP API. Instead, you must first encode it as a Base64 string. See the API reference.

<--- file.mp3

---> file.b64

  • Terminal

The encoder showcased is the base64 CLI tool available in most Linux distributions.

More encoding examples are provided in the API reference.

base64 -w 0 {file.mp3} >> {file.b64}
2

Upload the voice sample

Upload the Base64-encoded media file as a voice sample. See the API reference.

<--- ownerspacefile.b64

You must choose the handle for the sample. Optionally, you may choose the alias.

---> ✦ sample

  • Request

  • Response

  • Method — POST
  • Path — /spaces/{owner}/{space}/samples
  • Body — application/json
{
  "handle": "{sample}",
  "file": "{file.b64}"
}

Validation

1

Validate the voice sample details

To validate that the voice sample has been correctly uploaded, retrieve and analyze its details. See the API reference.

<--- ownerspacesample

  • Request

  • Response

  • Method — GET
  • Path — /spaces/{owner}/{space}/samples/{sample}
2

Validate the voice sample file

To validate that the voice sample has been correctly uploaded, retrieve and listen to its file. See the API reference.

<--- ownerspacesample

---> file.wav

  • Request

  • Response

  • Method — GET
  • Path — /spaces/{owner}/{space}/samples/{sample}/file