Log inGet started
Package

speech_to_text.service

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

speech_to_text

Turns recorded speech into text: the words spoken in a short audio clip, written as plain text. Push to talk (edui.voicePrompt) uses it to turn what a creator says into the prompt their agent receives.

One operation, transcribe, against the transcribe endpoint of the origozero/speech_to_text offering. A call costs 1 credit.

Input
audioVFS path of the clip: a WAV or an MP3 file. audio.encodeWav writes the WAV from what microphone.samples captured.
formatwav (the default) or mp3.

The framework reads the file, sends it base64 in the request with the instruction to write down the words spoken and nothing else, reads the answer at choices.1.message.content, and writes it to the asset_path the caller directs. The offering fixes the transcription model.

local pcm = microphone.samples()
local wav = audio.encodeWav(pcm, microphone.status().sampleRate, 1, { sampleRate = 16000 })
vfs.write("/zero/source/tmp/voice/clip.wav", wav, { overwrite = true })
local run = asset.resolve("speech_to_text", "service"):invoke({
    audio = "/zero/source/tmp/voice/clip.wav",
    asset_path = "/zero/source/tmp/voice/clip.txt",
})
-- Poll tools.use("services", "status", { id = run.id }) until `status` is
-- "completed"; the transcript is the file at the row's `asset`, and the
-- row's `charged` is what the call cost.