rustlavel-ai
Rustlavel AI: one API for Anthropic, OpenAI and Ollama, with streaming, tools and a fake provider — and speech to text with the time of every word, over Whisper or Deepgram.
Part of Rustlavel, a full-stack web framework for Rust written from scratch — no Axum, no hyper, no SeaORM. Tokio is the only large dependency.
Using it
Enable it through the meta-crate rather than depending on this one directly, so the versions stay in step:
[]
= { = "0.9", = ["ai"] }
Speech to text
A transcript for a clipping tool is a list of words and when each was said, so a cut at 42.5 seconds lands between two of them. That is what Transcript is; the paragraph is derived from it.
let speech = from_config?; // ai.transcribe.* / TRANSCRIBE_*
let transcript = speech
.transcribe // video is fine; the audio track is read server-side
.language
.prompt // names the model would otherwise misspell
.diarize // Deepgram only; Whisper refuses rather than pretending
.run
.await?;
transcript.words_between; // what the clip says
transcript.segments_between; // sentence edges to cut on
transcript.to_srt; // burn in with ffmpeg -vf subtitles=
transcript.speakers; // 2
Two wire formats, three deployments: Whisper speaks OpenAI's /v1/audio/transcriptions, which is also what a self-hosted faster-whisper server serves — Whisper::local("http://whisper.internal:8000"), no key — and Deepgram speaks /v1/listen with speakers told apart. Measured against fedirz/faster-whisper-server with a spoken clip: thirteen words, each with its time, and the hint turning "Rust Level" into "Rustlavel". FakeTranscriber::new().saying("…") lays words out half a second apart for tests.
Documentation
- API documentation
- The framework, including the roadmap and the design rules this crate is written under
Licence
MIT.