Automatic Speech Recognition
LiteRT-LM
LiteRT
VibeVoice
litertlm
on-device
edge
asr
speech-recognition
audio
bitnet
Instructions to use litert-community/VibeVoice-ASR-BitNet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT-LM
How to use litert-community/VibeVoice-ASR-BitNet with LiteRT-LM:
# LiteRT-LM runs on various platforms (Android, iOS, Windows, Linux, macOS, IoT, Web/WASM) # and supports many APIs (C++, Python, Kotlin, Swift, JavaScript, Flutter). # For platform-specific integration guides, please refer to the official developer website: # https://ai.google.dev/edge/litert-lm # To try LiteRT-LM, the easiest way is to use our CLI tool. # 1. Install the LiteRT-LM CLI tool: pip install -U litert-lm # 2. Download and run this model locally: # See: https://ai.google.dev/edge/litert-lm/cli # A single .litertlm file in the repo is picked automatically; otherwise the CLI asks which one to run # (or pass its name right after the repo id). litert-lm run \ --from-huggingface-repo=litert-community/VibeVoice-ASR-BitNet \ --prompt="Write me a poem"
- LiteRT
How to use litert-community/VibeVoice-ASR-BitNet with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- VibeVoice
How to use litert-community/VibeVoice-ASR-BitNet with VibeVoice:
import torch, soundfile as sf, librosa, numpy as np from vibevoice.processor.vibevoice_processor import VibeVoiceProcessor from vibevoice.modular.modeling_vibevoice_inference import VibeVoiceForConditionalGenerationInference # Load voice sample (should be 24kHz mono) voice, sr = sf.read("path/to/voice_sample.wav") if voice.ndim > 1: voice = voice.mean(axis=1) if sr != 24000: voice = librosa.resample(voice, sr, 24000) processor = VibeVoiceProcessor.from_pretrained("litert-community/VibeVoice-ASR-BitNet") model = VibeVoiceForConditionalGenerationInference.from_pretrained( "litert-community/VibeVoice-ASR-BitNet", torch_dtype=torch.bfloat16 ).to("cuda").eval() model.set_ddpm_inference_steps(5) inputs = processor(text=["Speaker 0: Hello!\nSpeaker 1: Hi there!"], voice_samples=[[voice]], return_tensors="pt") audio = model.generate(**inputs, cfg_scale=1.3, tokenizer=processor.tokenizer).speech_outputs[0] sf.write("output.wav", audio.cpu().numpy().squeeze(), 24000) - Notebooks
- Google Colab
- Kaggle
Card: the Python usage block now runs on litert-lm-api 0.16.1 / 0.17.1 (send_message returns a dict; response_text() helper)
Browse files
README.md
CHANGED
|
@@ -61,6 +61,8 @@ Sending the clip **without** the duration sentence works (the bundle's template
|
|
| 61 |
|
| 62 |
The audio goes in as an audio content item; any container/sample rate the runtime's decoder reads (wav, mp3, flac — it resamples to 24 kHz). The **audio encoder must run on the CPU** (`audio_backend`), the LM may run on CPU or GPU.
|
| 63 |
|
|
|
|
|
|
|
| 64 |
```python
|
| 65 |
import litert_lm
|
| 66 |
from litert_lm import Message, Contents, Content
|
|
@@ -70,11 +72,18 @@ engine = litert_lm.Engine("VibeVoice-ASR-BitNet.litertlm", backend=CPU(), audio_
|
|
| 70 |
dur = 5.86 # clip length in seconds
|
| 71 |
conv = engine.create_conversation(sampler_config=litert_lm.SamplerConfig(top_k=1, top_p=1.0, temperature=0.0),
|
| 72 |
max_output_tokens=256)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
resp = conv.send_message(Message.user(Contents.of([
|
| 74 |
Content.AudioFile("/abs/path/clip.wav"),
|
| 75 |
Content.Text(f"This is a {dur:.2f} seconds audio, please transcribe it."),
|
| 76 |
])))
|
| 77 |
-
print(
|
| 78 |
conv.close()
|
| 79 |
```
|
| 80 |
|
|
|
|
| 61 |
|
| 62 |
The audio goes in as an audio content item; any container/sample rate the runtime's decoder reads (wav, mp3, flac — it resamples to 24 kHz). The **audio encoder must run on the CPU** (`audio_backend`), the LM may run on CPU or GPU.
|
| 63 |
|
| 64 |
+
Python (`pip install litert-lm-api`; this block was run as written on 0.16.1 and 0.17.1):
|
| 65 |
+
|
| 66 |
```python
|
| 67 |
import litert_lm
|
| 68 |
from litert_lm import Message, Contents, Content
|
|
|
|
| 72 |
dur = 5.86 # clip length in seconds
|
| 73 |
conv = engine.create_conversation(sampler_config=litert_lm.SamplerConfig(top_k=1, top_p=1.0, temperature=0.0),
|
| 74 |
max_output_tokens=256)
|
| 75 |
+
|
| 76 |
+
def response_text(resp):
|
| 77 |
+
# litert-lm-api 0.15-0.17.1 return a dict of content parts; later builds return a Message whose str() is its text
|
| 78 |
+
if type(resp) is dict:
|
| 79 |
+
return "".join(p.get("text", "") for p in resp.get("content", []) if isinstance(p, dict))
|
| 80 |
+
return str(resp)
|
| 81 |
+
|
| 82 |
resp = conv.send_message(Message.user(Contents.of([
|
| 83 |
Content.AudioFile("/abs/path/clip.wav"),
|
| 84 |
Content.Text(f"This is a {dur:.2f} seconds audio, please transcribe it."),
|
| 85 |
])))
|
| 86 |
+
print(response_text(resp))
|
| 87 |
conv.close()
|
| 88 |
```
|
| 89 |
|