Skip to content

Kotlin + Jetpack Compose + MVVM + Clean Architecture + UiState + Hilt + Flow + Speech-to-Text + Text-to-Speech

Notifications You must be signed in to change notification settings

m9939418/AlexVoiceAssistantCompose

Repository files navigation

AlexVoiceAssistantCompose

一個使用 Kotlin + Jetpack Compose + Hilt 實作的「本地語音助理」範例專案。
整合 語音辨識(STT, Speech-to-Text)語音合成(TTS, Text-to-Speech)
並以 ViewModel + StateFlow 管理 UI 狀態,畫面由 Compose 建構。


📸 Demo



✅ 功能特色

  • 🎙 語音辨識(STT)

    • 使用 SpeechRecognizer + RecognitionListener
    • 支援 partial results(辨識中即時文字更新)
    • 完整結果會加入歷史列表,方便重播
  • 🔊 語音合成(TTS)

    • 透過 TextToSpeech 播放文字內容
    • 預設語系 Locale.TAIWAN,適合中文語音
  • 📜 辨識歷史清單

    • 每次完成辨識都會 append 到 history
    • 歷史每一項都有 TTS 按鈕可立即播放
      (UI:VoiceScreen,狀態:VoiceViewModel.UiState

🏗 專案架構(樹狀圖)

app/
 ├─ App.kt                      # Hilt Application
 ├─ MainActivity.kt             # 入口 Activity,載入 Compose UI
 ├─ core/
 │   ├─ di/
 │   │   └─ VoiceModule.kt      # 提供 STT / TTS Manager(Hilt Module)
 │   ├─ stt/
 │   │   ├─ Speech2TextManager.kt  # 封裝 SpeechRecognizer + SharedFlow 事件
 │   │   └─ Speech2TextEvent.kt    # STT 事件 sealed interface
 │   └─ tts/
 │       └─ TextToSpeechManager.kt # 封裝 TextToSpeech 管理
 └─ feature/
     └─ voice/
         ├─ VoiceScreen.kt      # 語音畫面 UI(History + 按鈕)
         └─ VoiceViewModel.kt   # 管理 UiState + STT/TTS 邏輯

👤 Author

Alex Yang
Android Engineer 🌐 github.com/m9939418

About

Kotlin + Jetpack Compose + MVVM + Clean Architecture + UiState + Hilt + Flow + Speech-to-Text + Text-to-Speech

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages