Get native stream of your microphone
npm install native-mic-capacitor
npx cap sync
isAvailable()
checkPermissions()
requestPermissions()
openAppSettings()
getDevices()
setPreferredInput(...)
setOutputRoute(...)
startCapture(...)
stopCapture(...)
setMicEnabled(...)
getState()
getDiagnostics()
webrtcIsAvailable()
webrtcConnect(...)
webrtcDisconnect(...)
webrtcForceReset(...)
webrtcSendDataMessage(...)
webrtcSetMicEnabled(...)
webrtcSetRemoteAudioEnabled(...)
webrtcSetPreferredInput(...)
webrtcSetOutputRoute(...)
webrtcGetState(...)
webrtcGetDiagnostics(...)
addListener('micStateChanged', ...)
addListener('micPcmChunk', ...)
addListener('micAudioLevel', ...)
addListener('micRouteChanged', ...)
addListener('micInterruption', ...)
addListener('micError', ...)
addListener('webrtcStateChanged', ...)
addListener('webrtcDataMessage', ...)
addListener('webrtcTrackStarted', ...)
addListener('webrtcTrackStopped', ...)
addListener('webrtcLocalAudioLevel', ...)
addListener('webrtcRemoteAudioLevel', ...)
addListener('webrtcError', ...)
removeAllListeners()
Interfaces
Type Aliases
isAvailable ( ) = > Promise < { available : boolean ; reason ?: string ; } >
Returns: Promise<{ available: boolean; reason?: string; }>
checkPermissions ( ) = > Promise < { microphone : MicPermissionState ; } >
Returns: Promise<{ microphone: MicPermissionState ; }>
requestPermissions ( ) = > Promise < { microphone : MicPermissionState ; } >
Returns: Promise<{ microphone: MicPermissionState ; }>
openAppSettings ( ) = > Promise < void >
getDevices ( ) = > Promise < { inputs : MicDevice [ ] ; selectedInputId ?: string ; } >
Returns: Promise<{ inputs: MicDevice[]; selectedInputId?: string; }>
setPreferredInput ( options : { inputId : string | null ; } ) = > Promise < void >
Param
Type
options
{ inputId: string | null; }
setOutputRoute ( options : { route : OutputRoute ; } ) = > Promise < void >
startCapture ( options : StartCaptureOptions ) = > Promise < StartCaptureResult >
Returns: Promise<StartCaptureResult >
stopCapture ( options : StopCaptureOptions ) = > Promise < StopCaptureResult >
Returns: Promise<StopCaptureResult >
setMicEnabled ( options : { captureId : string ; enabled: boolean ; } ) => Promise < void >
Param
Type
options
{ captureId: string; enabled: boolean; }
getState ( ) = > Promise < { state : 'idle' | 'running' | 'paused' ; } >
Returns: Promise<{ state: 'idle' | 'running' | 'paused'; }>
getDiagnostics ( ) = > Promise < Record < string , unknown > >
Returns: Promise<Record <string, unknown>>
webrtcIsAvailable ( ) = > Promise < { available : boolean ; reason ?: string ; } >
Returns: Promise<{ available: boolean; reason?: string; }>
webrtcConnect ( options : NativeWebRTCConnectOptions ) = > Promise < NativeWebRTCConnectResult >
Returns: Promise<NativeWebRTCConnectResult >
webrtcDisconnect ( options : { connectionId : string; reason ?: string ; } ) = > Promise < void >
Param
Type
options
{ connectionId: string; reason?: string; }
webrtcForceReset ( options ?: { reason ?: string | undefined ; } | undefined ) = > Promise < void >
Param
Type
options
{ reason?: string; }
webrtcSendDataMessage(...)
webrtcSendDataMessage ( options : { connectionId : string ; data: string ; } ) => Promise < void >
Param
Type
options
{ connectionId: string; data: string; }
webrtcSetMicEnabled ( options : { connectionId : string ; enabled: boolean ; } ) => Promise < void >
Param
Type
options
{ connectionId: string; enabled: boolean; }
webrtcSetRemoteAudioEnabled(...)
webrtcSetRemoteAudioEnabled ( options : { connectionId : string ; enabled: boolean ; } ) => Promise < void >
Param
Type
options
{ connectionId: string; enabled: boolean; }
webrtcSetPreferredInput(...)
webrtcSetPreferredInput ( options : { connectionId : string ; inputId: string | null ; } ) => Promise < void >
Param
Type
options
{ connectionId: string; inputId: string | null; }
webrtcSetOutputRoute(...)
webrtcSetOutputRoute ( options : { connectionId : string ; route: OutputRoute ; } ) => Promise < void >
Param
Type
options
{ connectionId: string; route: OutputRoute ; }
webrtcGetState ( options : { connectionId : string ; } ) = > Promise < NativeWebRTCStateResult >
Param
Type
options
{ connectionId: string; }
Returns: Promise<NativeWebRTCStateResult >
webrtcGetDiagnostics(...)
webrtcGetDiagnostics ( options : { connectionId : string ; } ) = > Promise < Record < string , unknown > >
Param
Type
options
{ connectionId: string; }
Returns: Promise<Record <string, unknown>>
addListener('micStateChanged', ...)
addListener ( eventName : 'micStateChanged' , listenerFunc : ( event : MicStateChangedEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('micPcmChunk', ...)
addListener ( eventName : 'micPcmChunk' , listenerFunc : ( event : MicPcmChunkEvent ) = > void ) => Promise < PluginListenerHandle >
Param
Type
eventName
'micPcmChunk'
listenerFunc
(event: MicPcmChunkEvent ) => void
Returns: Promise<PluginListenerHandle >
addListener('micAudioLevel', ...)
addListener ( eventName : 'micAudioLevel' , listenerFunc : ( event : MicAudioLevelEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('micRouteChanged', ...)
addListener ( eventName : 'micRouteChanged' , listenerFunc : ( event : MicRouteChangedEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('micInterruption', ...)
addListener ( eventName : 'micInterruption' , listenerFunc : ( event : MicInterruptionEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('micError', ...)
addListener ( eventName : 'micError' , listenerFunc : ( event : MicErrorEvent ) = > void ) => Promise < PluginListenerHandle >
Param
Type
eventName
'micError'
listenerFunc
(event: MicErrorEvent ) => void
Returns: Promise<PluginListenerHandle >
addListener('webrtcStateChanged', ...)
addListener ( eventName : 'webrtcStateChanged' , listenerFunc : ( event : NativeWebRTCStateChangedEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('webrtcDataMessage', ...)
addListener ( eventName : 'webrtcDataMessage' , listenerFunc : ( event : NativeWebRTCDataMessageEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('webrtcTrackStarted', ...)
addListener ( eventName : 'webrtcTrackStarted' , listenerFunc : ( event : NativeWebRTCTrackEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('webrtcTrackStopped', ...)
addListener ( eventName : 'webrtcTrackStopped' , listenerFunc : ( event : NativeWebRTCTrackEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('webrtcLocalAudioLevel', ...)
addListener ( eventName : 'webrtcLocalAudioLevel' , listenerFunc : ( event : NativeWebRTCAudioLevelEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('webrtcRemoteAudioLevel', ...)
addListener ( eventName : 'webrtcRemoteAudioLevel' , listenerFunc : ( event : NativeWebRTCAudioLevelEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
addListener('webrtcError', ...)
addListener ( eventName : 'webrtcError' , listenerFunc : ( event : NativeWebRTCErrorEvent ) = > void ) => Promise < PluginListenerHandle >
Returns: Promise<PluginListenerHandle >
removeAllListeners ( ) = > Promise < void >
Prop
Type
id
string
label
string
type
'built_in' | 'wired' | 'bluetooth' | 'usb' | 'unknown'
isDefault
boolean
Prop
Type
captureId
string
actualInputSampleRate
number
actualInputChannels
number
chunkMs
number
Prop
Type
profile
MicProfile
mode
SessionMode
outputStreams
OutputStream[]
chunkMs
number
emitAudioLevel
boolean
audioLevelIntervalMs
number
voiceProcessing
boolean
preferredInputId
string
outputRoute
OutputRoute
Prop
Type
captureId
string
totalFramesIn
number
totalFramesOut16k
number
totalFramesOut48k
number
durationMs
number
Prop
Type
captureId
string
flushTimeoutMs
number
NativeWebRTCConnectResult
NativeWebRTCConnectOptions
Prop
Type
connectionId
string
webrtcRequest
WebRTCRequestInfo
iceConfig
{ iceServers?: RTCIceServerLike[]; }
waitForICEGathering
boolean
audioOnly
boolean
audioCodec
string | null
videoCodec
string | null
media
{ voiceProcessing?: boolean; startMicEnabled?: boolean; preferredInputId?: string; outputRoute?: OutputRoute ; }
reconnect
{ enabled?: boolean; maxAttempts?: number; backoffMs?: number; }
Prop
Type
endpoint
string
headers
Record <string, string>
requestData
Record <string, unknown>
timeoutMs
number
Prop
Type
connectionId
string
state
NativeWebRTCState
pcId
string
iceConnectionState
string
signalingState
string
Prop
Type
remove
() => Promise<void>
Prop
Type
captureId
string
state
'idle' | 'running' | 'paused'
reason
string
Prop
Type
captureId
string
stream
OutputStream
sampleRate
16000 | 48000
channels
1
frames
number
seq
number
ptsMs
number
dataBase64
string
final
boolean
Prop
Type
captureId
string
rms
number
peak
number
dbfs
number
vad
boolean
ptsMs
number
Prop
Type
captureId
string
reason
string
selectedInputId
string
Prop
Type
captureId
string
phase
'began' | 'ended'
shouldResume
boolean
reason
string
Prop
Type
captureId
string
code
string
message
string
recoverable
boolean
nativeCode
string
NativeWebRTCStateChangedEvent
NativeWebRTCDataMessageEvent
Prop
Type
connectionId
string
data
string
Prop
Type
connectionId
string
kind
'audio' | 'video' | 'screenVideo'
source
'remote' | 'local'
NativeWebRTCAudioLevelEvent
Prop
Type
connectionId
string
level
number
Prop
Type
connectionId
string
code
NativeWebRTCErrorCode
message
string
recoverable
boolean
nativeCode
string
'prompt' | 'granted' | 'denied'
'system' | 'speaker' | 'receiver'
'waveform' | 'pipecat'
'measurement' | 'voice_chat'
'pcm16k_s16le' | 'pcm48k_s16le'
Construct a type with a set of properties K of type T
{
[P in K]: T;
}
'idle' | 'initializing' | 'connecting' | 'connected' | 'ready' | 'reconnecting' | 'disconnecting' | 'error'
{ urls: string | string[]; username?: string; credential?: string; }
'E_WEBRTC_UNAVAILABLE' | 'E_PC_CREATE_FAILED' | 'E_NEGOTIATION_FAILED' | 'E_ICE_FAILED' | 'E_DATA_CHANNEL_FAILED' | 'E_ALREADY_RUNNING' | 'E_NOT_RUNNING' | 'E_INVALID_ARGUMENT' | 'E_INTERNAL'