(Ffmpeg) Convert m4a call recording file to STT (⭐⭐⭐)

Date of creation
Name
(Ffmpeg) Convert m4a call recording file to STT (⭐⭐⭐)
Created by
  • data_popcorn

Practice environment

Mac OS M1 (Sonoma 14.6.1(23G93))

Workflow

Background

I'm trying to convert m4a files of recorded calls made with the default recorder on my Android phone into text using the openAI Transcription API.
M4a data sample for testing

Procedure

When I tried running cURL in the MacBook terminal, it said that m4a files were not supported.
If you check with file 07089191203_240710_194457.m4a, it is ISO Media, MPEG v4 system, 3GPP, but chatGPT responds that conversion is necessary because the codec recognized by the openAI API is different even though it is the same m4a file.
So, I tried converting this again with ffmpeg.
ffmpeg -i 07089191203_240710_194457.m4a -c:a aac -b:a 192k output.m4a
Before and after conversion comparison
(Former) ISO Media, MPEG v4 system, 3GPP
(After) ISO Media, Apple iTunes ALAC/AAC-LC (.M4A) Audio
Now that we've tested it locally, let's try it out on the n8n server.
curl https://api.openai.com/v1/audio/transcriptions \ -H "Authorization: Bearer <OPENAI_API_KEY>" \ -H "Content-Type: multipart/form-data" \ -F file=@output.m4a \ -F model="whisper-1" {"text":"이규리 시집 당신은 첫눈입니까? 상자 상자들을 두고 그들은 떠났다. 아래층에 맡겨둔 보물 아래층에 맡겨둔 약속을 아래층에 맡겨둔 질문을 아래층에 맡겨둔 당신의 아래층이 모두 가지세요. 그 상자를 나는 열지 않아요. 먼저온 꽃의 슬픔과 허기를 재울 때 고요이 찬 인연이 저물 때 생각해보면 가능이란 먼 것만은 아니었어요."}%

Process of installing ffmpeg on n8n server

*Not available on the cloud, only available on self-hosting.
Open the docker settings of your n8n server and proceed as follows.
1.
Check the container ID with docker ps.
Docker ps
1.
Connect with root privileges using the docker exec command.
Docker exec -it --user root [CONTAINER_ID] sh
apk add --no-cache ffmpeg
1.
Check if the installation was successful.
Ffmpeg -version
Now, let's download and install the workflow below from the n8n server.
1.
Import m4a file
1.
Read/Write Files from Disk
a.
Create a temporary file in the Docker server repository.
1.
Execute Command
Convert m4a to AAC.
1.
Read/Write Files from Disk
Re-read the converted file
1.
OpenAI API
Convert m4a files to text with Transcribe a Recording.