← Discover MCPs and Agents
A
AgentAI & MLGitHub

Android-MVVM-Architecture-Android-Voice-AI-SDK

Voice AI SDK is a reusable Android library that gives any app a full voice-driven AI conversation pipeline in minutes. Voice Assistant + Android Voide AI + SDK + MVVM + Kotlin

Links

README

From the repo.

Android Voice AI SDK in Model-View-ViewModel (ie MVVM)

Android Voice AI SDK Kotlin Coroutines Jetpack Compose Hilt MockK JUnit5 Espresso MVVM STT - Android SpeechRecognizer STT - OpenAI Whisper TTS - Android TTS TTS - ElevenLabs Anthropic Claude build: passing license: MIT minSdk: 24

MVVM3

flowchart LR
    Microphone --> AudioRecord --> VAD --> STT --> ClaudeAI["Claude AI"] --> TTS --> Speaker

The Android Voice AI SDK is a reusable Android library that gives any app a full voice-driven AI conversation pipeline in minutes. It captures audio from the device microphone, transcribes speech to text, sends the transcript to Anthropic Claude for an intelligent response, and speaks the reply back to the user through text-to-speech — all wired together with a single VoiceAISDK.Builder call. The SDK ships ready-to-drop-in Jetpack Compose UI components, swappable STT/TTS engine adapters, on-device emotion detection, and security utilities including PII redaction and encrypted key storage.

Features

LayerCapability
Audio InputVoice Activity Detection (VAD), noise handling, streaming PCM capture
RecognitionSpeech-to-Text (STT), language detection, speaker diarization
UnderstandingIntent extraction, entity recognition, conversation context
ActionAPI orchestration, workflow execution, task automation
ResponseLLM answer generation (Anthropic Claude)
Voice OutputText-to-Speech (TTS), voice style selection, audio streaming
SafetyUser consent, authentication, abuse prevention
AnalyticsConversation logs, session summaries, quality metrics

Requirements

RequirementVersion
Android StudioMeerkat or newer
Minimum SDK24 (Android 7.0)
Kotlin2.0+ (project uses 2.3.21)
Anthropic API keyRequired — obtain at console.anthropic.com

Quick Start

Step 1 — Add the dependency and manifest permissions

In your app build.gradle.kts:

dependencies {
    implementation("com.sdk:voice-ai-sdk:1.0.0")
}

In app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Step 2 — Hilt setup

Annotate your Application class with @HiltAndroidApp and your Activity with @AndroidEntryPoint:

@HiltAndroidApp
class MyApp : Application()

@AndroidEntryPoint
class MainActivity : ComponentActivity() { ... }

Step 3 — Add your API key to local.properties

local.properties is git-ignored, so your key never ends up in source control:

ANTHROPIC_API_KEY=sk-ant-...

Then expose it via BuildConfig in app/build.gradle.kts:

defaultConfig {
    buildConfigField(
        "String",
        "ANTHROPIC_API_KEY",
        "\"${project.findProperty("ANTHROPIC_API_KEY") ?: ""}\"",
    )
}

buildFeatures {
    buildConfig = true
}

Step 4 — Build the SDK

Provide the SDK through Hilt by creating an AppModule:

@Module
@InstallIn(SingletonComponent::class)
object AppModule {

    @Provides
    @Singleton
    fun provideVoiceAIConfig(): VoiceAIConfig =
        VoiceAIConfig(anthropicApiKey = BuildConfig.ANTHROPIC_API_KEY)

    @Provides
    @Singleton
    fun provideVoiceAISDK(
        @ApplicationContext context: Context,
        config: VoiceAIConfig,
    ): VoiceAISDK = VoiceAISDK.Builder(context)
        .anthropicApiKey(config.anthropicApiKey)
        .debugLogging(BuildConfig.DEBUG)
        .build()
}

Or construct the SDK directly without Hilt:

val sdk = VoiceAISDK.Builder(context)
    .anthropicApiKey(BuildConfig.ANTHROPIC_API_KEY)
    .debugLogging(true)
    .config { copy(systemPrompt = "You are a concise voice assistant.") }
    .build()

val session: VoiceAISession = sdk.createSession()
session.start()

Step 5 — Add the VoiceScreen composable

Use VoiceSessionPermissionGate to handle the RECORD_AUDIO runtime permission automatically, then place VoiceButton and ConversationView inside:

@Composable
fun VoiceScreen(viewModel: VoiceViewModel = hiltViewModel()) {
    VoiceSessionPermissionGate(
        rationale = "Microphone access is required for voice conversations.",
    ) {
        Column(
            modifier = Modifier
                .fillMaxSize()
                .padding(16.dp),
            verticalArrangement = Arrangement.SpaceBetween,
        ) {
            ConversationView(
                messages = viewModel.messages.collectAsStateWithLifecycle().value,
                modifier = Modifier.weight(1f),
            )
            VoiceButton(
                session = viewModel.session,
                modifier = Modifier.align(Alignment.CenterHorizontally),
            )
        }
    }
}

Architecture

The SDK is organised into six layers, each with a single responsibility:

LayerPackageResponsibility
Audioaudio/Raw PCM capture via AudioRecord, voice activity detection (VAD), audio level metering, and PCM-to-WAV conversion
STTstt/SpeechToTextEngine interface with a drop-in Android built-in implementation; plug in Whisper or any other engine
AIai/AIEngine interface backed by ClaudeAIEngine, which wraps the official Anthropic Java SDK and maintains conversation history
TTStts/TextToSpeechEngine interface with a drop-in Android built-in implementation; plug in ElevenLabs for premium voices
SessionVoiceAISessionOrchestrates the full pipeline — audio in, transcript out, AI reply, speech out — as a single coroutine-based lifecycle
UIui/Ready-to-use Jetpack Compose components: VoiceButton, ConversationView, VoiceSessionPermissionGate, WaveformVisualizer, LiveCaptionBanner, VoiceStatusIndicator

Available Engines

CategoryEngineClassNotes
STTAndroid built-inAndroidSttEngineDefault; free; uses android.speech.SpeechRecognizer; requires network
STTOpenAI WhisperWhisperSttEngineHigher accuracy; POSTs PCM/WAV to OpenAI REST API; requires OpenAI key
AIAnthropic ClaudeClaudeAIEngineDefault and only AI engine; uses com.anthropic:anthropic-java; model is configurable
TTSAndroid built-inAndroidTtsEngineDefault; free; uses android.speech.tts.TextToSpeech
TTSElevenLabsElevenLabsTtsEngineHigh-quality natural voices; POSTs to ElevenLabs REST API; requires ElevenLabs key
EmotionOn-devicebuilt-inLightweight on-device audio feature analysis; no external key required
EmotionHume AIHumeEmotionDetectorCloud-based; high accuracy across 7 emotions; requires Hume API key

Configuration Reference

All options are fields on VoiceAIConfig. Pass a config { } block to VoiceAISDK.Builder to override defaults.

FieldTypeDefaultDescription
anthropicApiKeyStringRequired. Your Anthropic API key. Never hardcode; read from BuildConfig or encrypted storage.
aiModelString"claude-3-5-sonnet-20241022"Claude model ID used for all AI turns.
systemPromptString?"You are a helpful voice assistant…"System instruction prepended to every conversation.
inputModeInputModeHANDS_FREEHANDS_FREE activates VAD; PUSH_TO_TALK records only while button is held.
localeLocaleLocale.getDefault()Locale passed to the STT engine for language hints.
silenceTimeoutMsLong1200Milliseconds of silence after speech before the STT turn is finalised.
maxHistoryTurnsInt20Maximum number of conversation turns kept in the Claude context window.
piiRedactionBooleanfalseWhen true, strips phone numbers, emails, and credit-card numbers from transcripts before sending to the AI.
emotionDetectionEnabledBooleanfalseEnables voice emotion detection. Requires user consent; set emotionConsentRationale.
certificatePinsList<String>emptyList()SHA-256 certificate pins applied to the OkHttp client for network requests.

Voice Emotion Detection

When enabled, the SDK analyses the acoustic features of each recorded utterance and annotates AI turns with the detected emotion (NEUTRAL, HAPPY, SAD, ANGRY, FEARFUL, SURPRISED, or DISGUSTED). Set emotionAwareAI = true to have the detected emotion automatically injected into the Claude system context so the AI can adapt its tone. Always present a clear consent rationale before enabling this feature.

val sdk = VoiceAISDK.Builder(context)
    .anthropicApiKey(BuildConfig.ANTHROPIC_API_KEY)
    .config {
        copy(
            emotionDetectionEnabled = true,
            emotionConsentRationale = "Emotion analysis helps the assistant respond more empathetically.",
            emotionAwareAI = true,
        )
    }
    .build()

Security

  • API keys are never hardcoded. Keys are read from BuildConfig fields populated via local.properties (git-ignored) or CI environment variables, never embedded in source files or strings.xml.
  • Encrypted local storage. VoiceAIKeyStorage wraps EncryptedSharedPreferences with AES-256-GCM key encryption and AES-256-SIV value encryption backed by the Android Keystore.
  • PII redaction. When piiRedaction = true, PiiRedactor strips phone numbers, email addresses, and credit-card numbers from transcripts before they leave the device.
  • Certificate pinning. Populate VoiceAIConfig.certificatePins with SHA-256 digests to enable OkHttp certificate pinning on all outbound API calls.
  • R8/ProGuard minification. Release builds should enable isMinifyEnabled = true; the Anthropic Java SDK ships consumer ProGuard rules that are merged automatically.

License

MIT License

Copyright (c) 2026 Android Voice AI SDK Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Collected info

  • 2,566 stars
  • 613 forks
  • Language: Kotlin
  • Source updated: 7/5/2026