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 of up to two minutes and receive the transcript in
a single JSON response, with optional per-word timestamps, speaker attribution and the audio
duration. The language is set per request with the language parameter (ja by default; see
the table below). 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
with_timestamps), speaker diarization (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.
A deployment whose model has no speaker tokens rejects the request.client.asr.transcribe, 0.2.0+;
diarization=True from 0.2.3).language parameter 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 |
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 used for the request; language_probability is 1.0 when
a language was supplied and 0.0 otherwise (the endpoint does not detect languages).
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 (kotoba-sdk 0.2.3+): 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.2.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/clientThe @fal-ai/serverless-client package has been deprecated in favor of @fal-ai/client. Install the new package and update your imports — see client setup.
Set 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"
});When running code on the client-side (e.g. in a browser, mobile app or GUI applications), make sure to not expose your FAL_KEY. Instead, use a server-side proxy to make requests to the API. For more information, check out our server-side integration guide.
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);The client will auto-upload the file for you if you pass a binary object (e.g. File, Data).
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
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.
{
"audio_url": "",
"language": "ja"
}language_code string* requiredtext string* requiredlanguage_probability float* requiredaudio_duration_secs float{
"language_code": "",
"text": "",
"words": [
{
"type": "word",
"text": ""
}
]
}file string* requiredAudio file to transcribe.
with_timestamps booleanInclude calibrated timestamp items in the response.
diarization booleanAttribute words and spacing to speakers. Times are null unless with_timestamps is enabled.
language stringInput language. Same format as input-streaming TTS open messages; defaults to the configured server language.
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
Keywords to use for the transcription. List of strings. Defaults to none.
kana boolean人名をカタカナで書き起こすかどうか。
type TypeEnumDefault value: "word"
Possible enum values: word, spacing, audio_event
speaker_id stringtext string* requiredstart floatend float