kotoba-technologies/kotoba-stt/v1/speech-to-text
Loading API documentation
Endpoint: POST https://fal.run/kotoba-technologies/kotoba-stt/v1/speech-to-text
Overview: Upload an audio or video file and receive the transcript in a single JSON
response, with optional per-word timestamps, speaker attribution and the audio duration. Send
the audio as a multipart file upload (file) or, as the Playground does, as a JSON body with an
audio_url (an https URL on fal's CDN or a base64 data: URI).
Use cases
Technical specifications
audio_url) and a
request with diarization=true take up to 120 seconds of audio.client.asr.transcribe).Request fields
| Field | Type and values | Default | Behavior |
|---|---|---|---|
file | file (multipart only) | required in a multipart upload | The audio or video file. |
audio_url | string: https URL on fal's CDN or base64 data: URI (JSON body only) | required in a JSON body | The audio to transcribe. |
language | string, see the language table below | "ja" in a multipart upload; required in a JSON body | Language spoken in the audio. |
with_timestamps | boolean | false | true fills words with start and end times. |
diarization | boolean | false | true attributes each word to a speaker (beta, see below). |
keywords | array of strings (multipart: repeat the field) | none | Up to 1,000 terms, 64 characters each, such as names or product words, whose spelling the transcript should prefer. |
kana | boolean | false | true writes personal and place names in katakana (Japanese). |
file_format | string: "other" or "pcm_s16le_16" (multipart only) | "other" | "pcm_s16le_16" for raw 16-bit little-endian PCM at 16 kHz mono; "other" for encoded audio or video. |
Speaker diarization: diarization=true attributes each word to a speaker (speaker_id:
speaker_1, speaker_2, …, numbered in order of first appearance). Word times are null unless
with_timestamps=true is also set. Beta: speaker attribution is produced by the model and can
differ between runs on the same audio, for example a short turn merged into its neighbour; the
transcript itself is unaffected. Works for every supported language; a word the model could not
attribute has speaker_id: null. words is filled when either flag is set.
Supported languages: pass the code in the language field exactly as written (lowercase).
Any other value returns an unsupported_language error.
| Language | language |
|---|---|
| Japanese (default) | ja |
| English | en |
| Korean | ko |
| Mandarin Chinese | zh |
| Mandarin Chinese (Taiwan) | zh-tw |
| Cantonese (Hong Kong) | zh-hk |
| Spanish | es |
| Detect automatically | auto |
Example request
curl -X POST https://fal.run/kotoba-technologies/kotoba-stt/v1/speech-to-text \
-H "Authorization: Key $FAL_KEY" \
-F file=@clip.wav -F language=ja -F with_timestamps=trueExample response
{
"language_code": "ja",
"language_probability": 1.0,
"text": "おはようございます。今日は水曜日です。",
"words": [
{"text": "おはようございます", "type": "word", "start": 0.12, "end": 0.98},
{"text": "今日は", "type": "word", "start": 1.10, "end": 1.42}
],
"audio_duration_secs": 8.0
}language_code echoes the language of the request. With auto the model picks the language
and language_code is auto; the response does not name the detected language.
words is filled when with_timestamps=true or diarization=true.
Example response with diarization=true and with_timestamps=true (two speakers)
{
"language_code": "ja",
"language_probability": 1.0,
"text": "おはようございます。
はい、わかりました。",
"words": [
{"text": "おはようございます", "type": "word", "start": 0.00, "end": 1.40, "speaker_id": "speaker_1"},
{"text": "。", "type": "word", "start": 1.40, "end": 1.42, "speaker_id": "speaker_1"},
{"text": "はい", "type": "word", "start": 4.80, "end": 5.10, "speaker_id": "speaker_2"},
{"text": "、わかりました。", "type": "word", "start": 5.10, "end": 6.10, "speaker_id": "speaker_2"}
],
"audio_duration_secs": 9.0
}With diarization on, text has a line break at each speaker change. With diarization=true
alone, speaker_id is set and start / end are null.
Example (Python)
import os
import requests
r = requests.post(
"https://fal.run/kotoba-technologies/kotoba-stt/v1/speech-to-text",
headers={"Authorization": f"Key {os.environ['FAL_KEY']}"},
files={"file": open("clip.wav", "rb")},
data={"language": "ja", "with_timestamps": "true"},
)
print(r.json()["text"])Example (Python SDK)
import kotoba
client = kotoba.KotobaClient() # KOTOBA_API_KEY + KOTOBA_ASR_REST_URL from the environment
result = client.asr.transcribe("clip.wav", language="ja", with_timestamps=True)
print(result.text)
for segment in result.segments or []:
print(segment.start, segment.end, segment.text)
# Speaker diarization: consecutive words grouped by speaker, in reading order
result = client.asr.transcribe("meeting.wav", language="ja", diarization=True, with_timestamps=True)
for u in result.utterances or []:
print(f"{u.start:6.2f} {u.speaker_id}: {u.text}")Pricing: $0.25 per hour of input audio (unit: second of input audio, $0.0000694 per second).
The kotoba-sdk package (PyPI, Python 3.10+, version 0.3.3 or newer) covers all four apps.
It sends the fal key with fal's Authorization: Key scheme automatically for fal.run URLs,
so use the fal key as the API key and point the per-route URLs at the apps.
pip install kotoba-sdk
export KOTOBA_API_KEY=<fal key>
export KOTOBA_ASR_REST_URL=https://fal.run/kotoba-technologies/kotoba-stt/v1
export KOTOBA_ASR_URL=wss://fal.run/kotoba-technologies/kotoba-streaming-stt/v1/realtime
export KOTOBA_TTS_URL=wss://fal.run/kotoba-technologies/kotoba-tts/v2/tts/ws
export KOTOBA_S2ST_URL=wss://fal.run/kotoba-technologies/kotoba-sts/v1/realtime_voiceAn app that has been idle may boot a GPU runner on the first request, which can take a few
minutes. Allow for that in the request timeout or retry the first request; the SDK's default
timeouts are 30 seconds for HTTP requests (KotobaClient(timeout=...)) and 15 seconds for the
WebSocket handshake.
The client provides a convenient way to interact with the model API.
npm install --save @fal-ai/clientSet FAL_KEY as an environment variable in your runtime.
export FAL_KEY="YOUR_API_KEY"The client API handles the API submit protocol. It will handle the request status updates and return the result when the request is completed.
import { fal } from "@fal-ai/client";
const result = await fal.subscribe("kotoba-technologies/kotoba-stt/v1/speech-to-text", {
input: {
audio_url: "",
language: "ja"
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS") {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
console.log(result.data);
console.log(result.requestId);The API uses an API Key for authentication. It is recommended you set the FAL_KEY environment variable in your runtime when possible.
import { fal } from "@fal-ai/client";
fal.config({
credentials: "YOUR_FAL_KEY"
});The client API provides a convenient way to submit requests to the model.
import { fal } from "@fal-ai/client";
const { request_id } = await fal.queue.submit("kotoba-technologies/kotoba-stt/v1/speech-to-text", {
input: {
audio_url: "",
language: "ja"
},
webhookUrl: "https://optional.webhook.url/for/results",
});You can fetch the status of a request to check if it is completed or still in progress.
import { fal } from "@fal-ai/client";
const status = await fal.queue.status("kotoba-technologies/kotoba-stt/v1/speech-to-text", {
requestId: "764cabcf-b745-4b3e-ae38-1200304cf45b",
logs: true,
});Once the request is completed, you can fetch the result. See the Output Schema for the expected result format.
import { fal } from "@fal-ai/client";
const result = await fal.queue.result("kotoba-technologies/kotoba-stt/v1/speech-to-text", {
requestId: "764cabcf-b745-4b3e-ae38-1200304cf45b"
});
console.log(result.data);
console.log(result.requestId);Some attributes in the API accept file URLs as input. Whenever that's the case you can pass your own URL or a Base64 data URI.
You can pass a Base64 data URI as a file input. The API will handle the file decoding for you. Keep in mind that for large files, this alternative although convenient can impact the request performance.
You can also pass your own URLs as long as they are publicly accessible. Be aware that some hosts might block cross-site requests, rate-limit, or consider the request as a bot.
We provide a convenient file storage that allows you to upload files and use them in your requests. You can upload files using the client API and use the returned URL in your requests.
import { fal } from "@fal-ai/client";
const file = new File(["Hello, World!"], "hello.txt", { type: "text/plain" });
const url = await fal.storage.upload(file);Read more about file handling in our file upload guide.
audio_url string* requiredSpeech to transcribe: an https:// URL on fal's CDN (Playground uploads and microphone recordings) or a base64 data: URI. Up to 2 minutes.
language LanguageEnum* requiredLanguage spoken in the audio.
Possible enum values: ja, en, ko, zh, es, zh-hk, zh-tw, auto
with_timestamps booleanReturn words with start and end times for each word.
diarization booleanAttribute words to speakers (speaker_id on each word; models with speaker tokens only). Word times are null unless with_timestamps is also set.
Up to 1000 terms of at most 64 characters, such as names or product words, whose spelling the transcript should prefer.
kana booleanWrite personal and place names in katakana (Japanese).
{
"audio_url": "",
"language": "ja"
}language_probability float* requiredaudio_duration_secs floattext string* requiredlanguage_code string* required{
"text": "",
"language_code": "",
"words": [
{
"type": "word",
"text": ""
}
]
}with_timestamps booleanInclude calibrated timestamp items in the response.
diarization booleanAttribute words and spacing to speakers. Times are null unless with_timestamps is enabled.
kana boolean人名をカタカナで書き起こすかどうか。
file_format FileFormatEnumInput audio format. Use pcm_s16le_16 for raw 16-bit little-endian PCM at 16kHz mono; use other for encoded audio/video files. Default value: "other"
Possible enum values: pcm_s16le_16, other
file string* requiredAudio file to transcribe.
language stringInput language, case-insensitive (e.g. ja, zh-hk). "auto" lets the model detect the language where the server lists it. Defaults to the configured server language.
Keywords to use for the transcription. List of strings. Defaults to none.
end floatstart floattype TypeEnumDefault value: "word"
Possible enum values: word, spacing, audio_event
speaker_id stringtext string* required