跳转到内容

Expo / React Native 接入

对应示例:examples/react-native-expo

完整绑定见示例中的 expo-adapters.ts

Terminal window
cd examples/react-native-expo
cp .env.example .env # 按需配置 broker / 模型
bun run start

推荐输入:16 kHz · mono · PCM16。Runtime 不硬依赖 Expo 包,由你注入小型接口:

import { createExpoRuntime } from '@ottervoice/runtime-react-native';
import { createVoiceSession } from '@ottervoice/core';
const runtime = createExpoRuntime({
input: { /* Expo AudioStream / 录音绑定 */ },
output: { /* AudioPlaylist / 播放绑定 */ },
});
const session = createVoiceSession({
mode: 'full_duplex',
pipeline: 'audio_llm', // 示例默认走 Audio LLM
audioLlmStartTiming: 'after_audio', // 终句字幕 ASR 与回复并行。
runtime,
providers: { asr, llm, audioLlm },
});

采集分两路:

  • delivery: 'stream' — 小 PCM 缓冲 → 流式 ASR
  • delivery: 'turn' — 完整 WAV → batch ASR / Audio LLM

追求最低语音首响时使用 audioLlmStartTiming: 'after_audio'。兼容默认值 after_asr_final 会先等待权威终句字幕,以免自然停顿被后续语音覆盖时仍产生 一次付费回复请求。

助手播放期间可暂停编码采集,但保留音量回调以继续 barge-in。细节见 runtime-react-native