Skip to content

Речь в текст

AI Core может использовать native local Whisper provider для speech-to-text, если runtime artifact поддерживает эту возможность. SDK users не нужен исходный crate speech-whisper; им нужен совместимый AI Core artifact и local Whisper model file.

Требования

Используйте AI Core runtime artifact с local speech-to-text support для вашей platform. Скачайте или подготовьте совместимый ggml Whisper model:

text
ggml-large-v3-turbo.bin

Это только speech recognition model. Это не LLM и не может использоваться для routing, reasoning или chat.

AI Core сейчас ожидает WAV PCM16 или raw PCM16 input на provider boundary. Hosts должны конвертировать M4A, MP3, FLAC, OGG, WebM или platform recorder formats в WAV/PCM перед вызовом runtime.

Приоритет путей к model

Когда runtime использует helper для default Whisper model path, порядок такой:

  1. SPEECH_WHISPER_MODEL=/absolute/path/to/ggml-large-v3-turbo.bin
  2. SPEECH_WHISPER_MODEL_DIR=/absolute/path/to/models/whisper
  3. platform app data fallback, например на macOS: ~/Library/Application Support/AI Core/models/whisper/ggml-large-v3-turbo.bin

Для app bundles положите model в app resources directory:

text
Your.app/Contents/Resources/models/whisper/ggml-large-v3-turbo.bin

Для services или CLI deployments положите model в стабильный local directory и задайте:

sh
export SPEECH_WHISPER_MODEL_DIR=/opt/ai-core/models/whisper

Для user-selected models храните выбранный absolute file path в host-owned settings и передавайте его в runtime config вместо directory scans.

FFI config

Настраивайте speech через обычный AI Core config snapshot. В ai-core-ffi, этот native provider подключается только когда shared library собрана с builtin-speech-whisper или builtin-local-all.

json
{
  "speech": {
    "whisper": {
      "model_path": "/models/whisper/ggml-large-v3-turbo.bin",
      "coreml_encoder_path": null,
      "language": "auto",
      "max_concurrent_requests": 1,
      "max_pending_requests": 0
    }
  }
}

Политика language:

  • config language - provider-level override;
  • request locale - per-request hint from host;
  • effective precedence: config language, затем request locale hint, затем auto.

Concurrency and memory policy:

  • max_concurrent_requests defaults to 1 and must be greater than zero.
  • max_pending_requests defaults to 0, so a concurrent call is rejected while the active Whisper slot is busy instead of waiting inside Core.
  • Rust hosts can use UNBOUNDED_CONCURRENT_REQUESTS, and JSON hosts can pass 4294967295, for an effectively unbounded active limit. That is a deliberate memory-risk choice and should require external backpressure.
  • The native provider keeps a resident whisper_context pool per process/model path after first use. With defaults, that pool has one context.
  • Raising max_concurrent_requests allows more simultaneous transcriptions, but each active slot needs its own native Whisper context memory.
  • Separate OS processes do not share the pool. A pool of four worker processes can load four Whisper context pools.

Use the host service, UI, or job system for durable queues, retries and backpressure. max_pending_requests is only an in-process admission queue.

FFI build variants:

sh
# Native Whisper transcription only.
cargo build -p ai-core-ffi --release --features builtin-speech-whisper

# Native Whisper transcription plus native local GGUF chat.
cargo build -p ai-core-ffi --release --features builtin-local-all

FFI hosts call ai_core_transcribe_audio_json with host-owned audio bytes and a small request JSON:

json
{
  "format": "pcm16",
  "sample_rate_hz": 16000,
  "locale": "ru-RU"
}

The function is exported even in FFI artifacts without builtin-speech-whisper, but those artifacts return transcription_provider_unavailable instead of loading a Whisper model.

CLI usage

sh
ai-core run-audio /path/to/input.wav --language ru --debug

run-audio сначала транскрибирует audio, а затем пропускает transcript через тот же model/plugin flow, что и run-text. Whisper provider определяет путь к модели через SPEECH_WHISPER_MODEL, затем SPEECH_WHISPER_MODEL_DIR, затем platform fallback path для ggml-large-v3-turbo.bin. Используйте --debug, чтобы вывести transcript до routing.

Core ML encoder

Некоторые macOS artifacts могут поддерживать Core ML acceleration. Для таких развёртываний нужен дополнительный encoder artifact рядом с ggml model:

text
models/whisper/ggml-large-v3-turbo.bin
models/whisper/ggml-large-v3-turbo-encoder.mlmodelc/

Если выбранный AI Core artifact требует Core ML, проверьте оба пути до включения local transcription в host UI. Если хотя бы один файл отсутствует, скрывайте или отключайте local speech-to-text вместо создания provider.

AI Core documentation site.