|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > AI - Artificial Intelligence Commands > AIU. - OpenAI API > !Core Operations > AIU. - Artificial Intelligence Utility |
MiniRobotLanguage (MRL)
AIU.SpeechToText
Transcribes an audio file to text using the Whisper API.
Intention
The AIU.SpeechToText command (aliased as AIU.Stt) converts spoken audio from a file into written text. It sends the audio data to the OpenAI Whisper API, which processes it and returns an accurate transcription. This is incredibly useful for automating tasks that involve processing voice notes, meeting recordings, or any other audio input.
It’s your robot’s ear—AIU.SpeechToText listens to an audio file and tells you exactly what was said.
Illustration
┌──────────────────────────────┐
│ Audio File (audio.mp3) │
├──────────────────────────────┤
│ "Hello, world." │
├────────────┬─────────────────┤
│ AI Whisper │ Result │
├────────────┼─────────────────┤
│ Processes… │ "Hello, world." │
└────────────┴─────────────────┘
Converting an audio file into text.
Syntax
AIU.SpeechToText|$$PTH|$$RET
Parameter Explanation
P1 - $$PTH - (Variable, String, Required)
The full path to the audio file to be transcribed (e.g., "C:\audio\meeting.mp3").
P2 - $$RET - (Variable, String, Required)
The variable where the transcribed text will be stored. On failure, this variable will be empty.
Examples
'***********************************
' AIU.SpeechToText - Sample 1: Basic Transcription
'***********************************
VAR.$$KEY=sk-YourSecretKeyHere
AIU.SetKey|$$KEY
VAR.$$PTH=?path\audio_sample.mp3
AIU.SpeechToText|$$PTH|$$TXT
' Check for errors from the API call
AIU.GetLastError|$$ERR
JNZ.$$ERR|Lab_failed
MBX.Transcription Result:|$$TXT
END.
Remarks
- The alias AIU.Stt can be used for convenience.
- The transcription model can be changed using the AIU.SetSttModel command. The default is "whisper-1".
- Supported audio file formats include mp3, mp4, mpeg, mpga, m4a, wav, and webm.
- On failure, an error is set which can be retrieved with AIU.GetLastError and AIU.GetLastErrorMsg.
See also: