От Api Dojo | Обновлено לפני חודשיים | Music

9.8 / 10



Уровень обслуживания


Health Check


Назад ко всем руководствам (1)

How to use .../songs/detect endpoint

Hello everyone,

Firstly, you need to generate your own raw sound from a recording device (directly from your phone mic for example). You also make quick test by converting any audio files from other format (mp3, wav, etc…) to raw data by using any Audio application such as Audacity Remember that all audio files are NOT mono, so you always have to remove one channel to make the sound mono. In addition, you need to Import the raw file (not Open ) to Audacity and play the sound to test whether it is working or not.

Secondly, you write some logic code to read the raw file by using input file stream to get byte[], then convert the byte[] to base64 string and send base64 string in body via POST requests with body as plain text by using any HTTP client tools, such as :

String inputRawFile = ".../clinteastwood_portion_mono.raw";
byte[] byteArray = readFile(inputRawFile);
String base64Str = Base64.getEncoder().encodeToString(byteArray);
try (OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(".../clinteastwood_portion_mono.txt"), StandardCharsets.UTF_8)) { out.write(base64Str); }

You may download sample raw sound data from the following link :