
Haru-4B: multilingual full-duplex spoken dialogue model
Haru is a low-latency and multilingual full-duplex spoken dialogue model: it
以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。
Model · Technical blog · Technical blog (Japanese)
Haru is a low-latency and multilingual full-duplex spoken dialogue model: it listens and speaks at the same time, the way people do on a phone call. This repository contains the inference code for Haru-4B, a pretrained base model, with three implementations and a web demo.
Directory What it is
haru/ PyTorch implementation, web demo server, offline inference
haru_mlx/ MLX implementation for Apple silicon, with a native macOS app
haru_vllm/ Plugin that serves Haru with vLLM-Omni
client/ Web client of the demo (React); a built copy ships inside haru
All three read the same checkpoint, higurashi-ai/Haru-4B.
With an NVIDIA GPU (about 12 GB of memory):
pip install -e ./haru python -m haru.server --hf-repo higurashi-ai/Haru-4B
Open http://localhost:8998, pick a character, give the model a voice, and talk. A browser only gives a page microphone access on localhost or over HTTPS.
For low latency, we recommend wired headphones and a wired microphone. Bluetooth devices add 100 ms or more.
To let someone else try it, add --share (pip install -e "./haru[share]"): the server prints a public HTTPS link that tunnels to it. Anyone with the link can use the demo, and the traffic passes through Gradio's share servers.
Bring your own voice. Haru ships without voice clips. In the demo, upload or record a clip of the voice the model should speak with: one speaker, 3 seconds to 3 minutes, clean speech. In Python, pass it as reference. Only use voices you have the right to use.
To give the demo a default voice, save a clip as haru/haru/assets/voices/<language>.flac (en.flac, ja.flac, ...) and restart the server: the demo then offers it as the default voice of that language. Without the file, the demo does not show the option.
On a Mac with Apple silicon, build the native app (see haru_mlx/swift):
cd haru_mlx python3 -m venv .venv && source .venv/bin/activate pip install -e . cd swift && ./build_app.sh # then open build/Haru.app
Python
from haru import DuplexSession, HaruModel from haru.audio import load_audio, prepare_reference
model = HaruModel.from_pretrained("higurashi-ai/Haru-4B") voice = prepare_reference(load_audio("voice.wav")) session = DuplexSession(model, system_prompt=card, reference=voice)
frame = session.start() # the model's first 133 ms: frame.audio, frame.text while not frame.done: frame = session.step(user_audio) # 3200 samples at 24 kHz in, 3200 out
The model is one frame ahead of the user: start() returns frame 0, and each step() with user frame k returns model frame k + 1.
Haru reads its character from a card with a fixed layout. Build one with render_card:
from haru.prompt import card_templates, render_card
card = render_card( { "persona": "Haru is a 29-year-old nurse in Denver. She is warm, chatty and laughs easily.", "name": "Haru", "gender": "female", "other_name": "Sam", "relationship": "Old friends from high school.", "situation": "A phone call to catch up after a long time.", }, card_templates()["templates"]["en"], )
Offline
haru-inference user.wav reply.wav --reference voice.wav --system-prompt "$(cat card.txt)" --stereo
Serving with vLLM-Omni
For many concurrent conversations and the lowest latency on a GPU server, see haru_vllm/. The web demo can use it as its engine:
python -m haru.server --backend vllm --vllm-url http://localhost:8000
Custom kernels
The hot paths of a frame have hand-written kernels, alongside plain implementations that give the same results:
Haru-4B is a pretrained base model, released for research. It holds a natural conversation, but it is not a reliable source of facts and does not follow instructions the way an assistant does. It can imitate the voice of a reference clip; only use voices you have the right to use.
The code and the Haru-4B weights are released under the Apache License 2.0. See THIRD_PARTY_NOTICES.md for the third-party work they include.
Haru builds on the work of many open-source projects. We are grateful to their authors and communities.
正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。