* fix(app): hold the loading screen until first-run setup is decided A new user saw the empty home, the sidebar and a logo jump before setup popped in. Startup now keeps the splash while setup may still open over the empty home, for at most 3 s and only while the setup host is reachable. Remembered-workspace restore does not wait. Web dialogs now fade in as they already fade out. (cherry picked from commita0a7620b62) (cherry picked from commit72d7c0bf26) * fix(app): fade the dialog card in and land the dim at once (cherry picked from commit6ef05705a0) (cherry picked from commit71c28b431c) * fix(app): keep the loading screen up while startup redirects (cherry picked from commit0b28d4cbff) (cherry picked from commit13cc485e6f) * test(app): cover a setup host that drops while startup waits (cherry picked from commit2a906ef83e) (cherry picked from commit7b6e21207a) * fix(app): type the web-only dialog enter animation style The CSS animation props are not part of ViewStyle. CI typechecks without the generated expo-env.d.ts, which declares them, so the cast is required there. (cherry picked from commitb887d979d2) * fix(app): keep the setup window mounted when the theme changes The shell's appearance boundary remounts its dialog hosts whenever a theme color changes, so picking a theme in setup, or a system light/dark switch, replaced the open setup window and replayed its fade. Setup draws colors through CSS variables and themed props, which update in place, and changes no font size, so it now sits outside that remount. The dialog enter fade is skipped with reduced motion, and its style is typed for CI, which typechecks without the generated expo-env.d.ts. (cherry picked from commitb24c6eacf8) (cherry picked from commitcb0e9907f5) * docs(changelog): prepare 0.15.2 (cherry picked from commit5af1a8ff66) * chore(release): cut 0.15.2 (cherry picked from commite896c05b09)
Speechmatics Two Way Audio
Expo module for capturing and playing pcm audio data in react-native apps (iOS and Android).
The aim of the module is to facilitate creating real-time conversational apps. The following features are provided:
- Request audio recording permissions
- Get clean (applying Acoustic Echo Cancelling) microphone samples in PCM format (1 channel 16 bit at 16kHz)
- Play audio samples in PCM format (1 channel 16 bit at 16kHz). Playback happens through main speaker unless external audio sources are connected.
- Provide volume level both for the input and output samples. Float between 0 and 1.
- [iOS only] Get microphone mode and prompt user to select a microphone mode.
Check out our examples/ to see the module in action.
Installation
npm i @speechmatics/expo-two-way-audio
Usage
Please check out our examples/ to get full sample code.
-
Request permissions for recording audio
import {useMicrophonePermissions} from "@speechmatics/expo-two-way-audio"; const [micPermission, requestMicPermission] = useMicrophonePermissions(); console.log(micPermission); -
Initialize the module before calling any audio functionality.
useEffect(() => { const initializeAudio = async () => { await initialize(); }; initializeAudio(); }, []); -
Play audio
Note
The sample below uses the
buffermodule:npm install bufferimport { Buffer } from "buffer"; // As an example, let's play pcm data hardcoded in a variable. // The examples/basic-usage does this. Check it out for real base64 data. const audioChunk = "SOME PCM DATA BASE64 ENCODED HERE" const buffer = Buffer.from(audioChunk, "base64"); const pcmData = new Uint8Array(buffer); playPCMData(pcmData); -
Get microphone samples
// Set up a function to deal with microphone sample events. // In this case just print the data in the console. useExpoTwoWayAudioEventListener( "onMicrophoneData", useCallback<MicrophoneDataCallback>((event) => { console.log(`MIC DATA: ${event.data}`); }, []), ); // Unmute the microphone to get microphone data events toggleRecording(true);
Notes
Some audio features of expo-two-way-audio like Acoustic Echo Cancelling, noise reduction or microphone modes (iOS) don't work on simulator. Run the example on a real device to test these features.
# iOS
npx expo run:ios --device --configuration Release
# Android
npx expo run:android --device --variant release
For Android, the following permissions are needed: RECORD_AUDIO, MODIFY_AUDIO_SETTINGS. In Expo apps they can be added in your app.json file:
expo.android.permissions: ["RECORD_AUDIO", "MODIFY_AUDIO_SETTINGS"]