Skip to main content
LFM3-Audio is a single end-to-end speech model: it listens to audio, reads text, and answers in text, speech, or interleaved text and speech. One model covers speech recognition, text-to-speech, speech translation, spoken chat, and tool calling from spoken requests. The examples below use LFM3-Audio-2B with Transformers. For images and video as well as audio, see Omni Capabilities.

Setup

Install Transformers and the packages used by the examples. librosa and soundfile load and save audio files, and datasets loads a sample recording. A GPU is recommended; the model runs in bfloat16.
Load the model and processor with trust_remote_code=True. The processor bundles the audio codec, which turns generated speech codes into a 24 kHz waveform. Access it as processor.audio_tokenizer and move it to the model’s device. Keep the codec in its own precision; don’t cast it to bfloat16.

Output modes

Every task is a chat conversation, and the system prompt describes the task. Text output is the default: generation starts in text mode and switches to speech or interleaved output when the model emits an output-mode token. To select a mode from the start, prefill the assistant turn: put one of the prefixes below in a final assistant message and let the model continue it. The thinking prefixes are for text-only answers. For those, also pass suppress_mixed=True and suppress_audio_out=True to generate(), so the model doesn’t switch to speech.

Helper

The helper below runs one assistant turn and returns the text and the speech waveform, if any. When you pass prefill, it sets continue_final_message=True, so generation continues the prefilled message instead of starting a new assistant turn. For speech and interleaved output, pass SPEECH_SAMPLING. These values are also the defaults in the model’s generation_config.json; passing them explicitly keeps the examples reproducible.

Speech recognition

Use the system prompt Perform ASR in <language>. with the English name of the language, or Perform ASR. to let the model detect it. Pass audio in the user turn as {"type": "audio", "audio": ...}, where the value is a file path or URL. The processor resamples it to 16 kHz mono. This example transcribes a LibriSpeech clip:
Output

Live speech recognition

Live speech recognition transcribes speech while it is still being spoken, instead of waiting for the full recording. Use the system prompt Perform live ASR.. It currently supports English only. The model processes audio in chunks of about 0.96 s and writes the text for each chunk as soon as the chunk arrives. model.transcribe_live() runs one chunk at a time and returns a state that you pass to the next call. In an application, you open a microphone stream into the model and a text stream out of it. This example simulates the microphone by feeding the LibriSpeech clip in 100 ms pieces:
Output
For streams longer than 30 seconds, pass input_ids=prompt again to start a new text context. The encoder keeps following the audio stream.

Text-to-speech

Use the system prompt Perform TTS in <language> using a <female|male> voice. and prefill <|audio_start|>. Supported languages and accents: Arabic, Danish, German, Greek, British English, American English, Finnish, French, Hebrew, Italian, Japanese, Korean, Dutch, Polish, Portuguese, Spanish, Swedish, Turkish, and Chinese.
As a quick check, let the model transcribe its own French speech:
Output

Speech translation

LFM3-Audio translates speech into text. Translation works best into or out of English. Name the source and target languages in the system prompt, for example Convert the speech in {source} to written {target}. or Translate the following speech from {source} to {target} in text form. The model was trained on many phrasings, so pick the one that works best for your data. For text-to-text translation, use the text model LFM3-1.7B instead. This example translates the French clip from the text-to-speech example into English:
Output

Spoken chat

With the system prompt Respond with interleaved text and audio. and the <|mixed_start|> prefill, the model answers conversationally in text and speech at the same time, so speech can start playing before the full answer is written. Keep the system prompt exactly as shown, and give any further instructions in the user turn. This example first records a spoken question with text-to-speech, then asks it:
Output (text part; the speech is saved to reply.wav)
For streaming applications, model.generate() accepts streamer for text tokens and audio_streamer for speech frames, and the codec decodes those frames incrementally, so speech can be played as it is generated.

Speech-to-text chat

In this mode, the model behaves like a text LLM that also accepts speech. No system prompt is needed. Prefill <think> to let the model reason first; it closes the reasoning with </think>, and the answer follows. Pass suppress_mixed=True and suppress_audio_out=True to keep the answer in text.
Output (truncated)
To skip thinking, prefill an empty <think></think> block, so the answer starts immediately:

Audio understanding

Text and audio can be mixed in the same user turn, for example a recording plus a written question about it. Questions can address speech, music, background sounds, or events.
Output

Tool calling

This example turns one spoken request into two function calls: cancel a streaming-platform subscription at the end of the billing period, then subscribe to a podcast platform’s Max plan with monthly billing. StreamBox and PodSpace are fictional services, and the example only prints the proposed calls. List the tools in the system prompt, between <tools> and </tools>, one JSON object per line. The user asks by voice, and the model returns one <tool_call> block per call.
Output
Generated calls use the LFM3 <tool_call> XML format. Your application parses and executes the calls and returns the results as tool messages. See Tool Use for the full workflow. Don’t prefill a thinking block for tool calls; the model calls tools without reasoning first. To get a spoken answer once the tool results are in, start the system prompt with Respond with function calls, and interleaved text and audio.\n\n, followed by any instructions and the tool list, and don’t pass suppress_mixed or suppress_audio_out. The model then either calls tools or answers in interleaved text and speech. The model card’s tool calling example shows the full loop, including returning tool results.

FAQ

Which model should I use? Use LFM3-Audio-2B for speech and audio tasks: transcription, speech synthesis, translation, spoken chat, audio understanding, and spoken tool calls. Use LFM3-Omni-2B when the request also involves images or video. See Omni Capabilities. What audio input is supported? Audio files are resampled to 16 kHz mono on load. Speech output is a 24 kHz waveform. Can the model stream speech? Yes. LFM3-Audio-2B uses a causal audio encoder that supports live audio input (see Live speech recognition), and its audio codec supports streaming decoding. In Transformers, pass streamer and audio_streamer to model.generate(). Does the model reason before answering? For text-only answers, prefill <think> to let the model reason first, or <think></think> to answer directly.