iOS speech-to-text module for Expo for real-time transcription
1 month ago
7
A native iOS speech-to-text module for Expo applications, built using Apple's Speech framework. This module provides real-time speech recognition with multi-language support, audio visualization, and comprehensive event handling. And will be used in the PANOT app.
Multi-language support (English, Spanish, French, Italian, German, Portuguese, and more)
Audio level monitoring for visualizations and animations
Confidence scores for transcription accuracy
iOS native implementation using Apple's Speech framework
Comprehensive permission handling with Expo's permission system
Event-driven architecture with real-time updates
Thread-safe implementation using Swift actors
TypeScript support with full type definitions
Performance optimized with DSP-accelerated audio processing
or
Add the following permissions to your app.json or app.config.js:
{
"expo": {
"ios": {
"infoPlist": {
"NSMicrophoneUsageDescription": "This app needs access to microphone for speech recognition.",
"NSSpeechRecognitionUsageDescription": "This app needs speech recognition to convert your speech to text."
}
}
}
}
After installing, rebuild your iOS app:
importPanotSpeechModulefrom"panot-speech";import{useEffect,useState}from"react";functionApp(){const[transcript,setTranscript]=useState("");useEffect(()=>{// Listen for transcript updatesconstsub=PanotSpeechModule.addListener("onTranscriptUpdate",(event)=>{setTranscript(event.transcript);console.log("Confidence:",event.confidence);console.log("Is Final:",event.isFinal);});return()=>sub.remove();},[]);conststartRecording=async()=>{// Request permissionsconstresult=awaitPanotSpeechModule.requestPermissions();if(result.status==="granted"){// Start transcribing with interim results in EnglishPanotSpeechModule.startTranscribing(true,"en-US");}};conststopRecording=()=>{PanotSpeechModule.stopTranscribing();};return(<><Text>{transcript}</Text><Buttontitle="Start"onPress={startRecording}/><Buttontitle="Stop"onPress={stopRecording}/></>);}
requestPermissions(): Promise<PermissionResponse>
Requests both microphone and speech recognition permissions.
interimResults (optional): Show partial results as you speak (default: true)
lang (optional): Language code (default: "en-US")
Examples:
// Basic usage (English with interim results)PanotSpeechModule.startTranscribing();// Spanish with interim resultsPanotSpeechModule.startTranscribing(true,"es-ES");// French without interim results (only final)PanotSpeechModule.startTranscribing(false,"fr-FR");
Stops the current speech recognition session.
PanotSpeechModule.stopTranscribing();
Stops recognition and clears the current transcript.
Fired when the transcript is updated (partial or final results).
interfaceTranscriptUpdateEvent{transcript: string;// The recognized textisFinal: boolean;// Whether this is a final resultconfidence: number;// Confidence score (0.0 to 1.0)}PanotSpeechModule.addListener("onTranscriptUpdate",(event)=>{console.log(event.transcript);});
Fired periodically with audio input level (for visualizations).
interfaceVolumeChangeEvent{volume: number;// Range: -2 to 10 (normalized audio level)}PanotSpeechModule.addListener("onVolumeChange",(event)=>{constnormalized=(event.volume+2)/12;// Convert to 0-1// Use for animations, visualizations, etc.});