In this guide you will learn how to upload a media file as an audio 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 an audio 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 an audio, 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

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 audio

Upload the Base64-encoded media file as an audio. See the API reference.

<--- ownerspacefile.b64

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

---> ✦ audio

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

Validation

1

Validate the audio details

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

<--- ownerspaceaudio

  • Method — GET
  • Path — /spaces/{owner}/{space}/audios/{audio}
2

Validate the binary file

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

<--- ownerspaceaudio

---> file.wav

  • Method — GET
  • Path — /spaces/{owner}/{space}/audios/{audio}/file