Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
local.properties
.kotlin
ktlint
ktlint.bat
ktlint.bat
whisper/build/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "llama.cpp"]
path = llama.cpp
url = https://github.com/ggerganov/llama.cpp
[submodule "whisper/src/main/jni/whisper.cpp"]
path = whisper/src/main/jni/whisper.cpp
url = https://github.com/ggml-org/whisper.cpp.git
7 changes: 6 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.compose)
id("com.google.devtools.ksp")
kotlin("plugin.serialization") version "2.1.0"
kotlin("plugin.serialization") version "2.0.0"
}

android {
Expand Down Expand Up @@ -92,12 +92,17 @@ dependencies {

implementation(project(":smollm"))
implementation(project(":hf-model-hub-api"))
implementation(project(":whisper"))

// Android Wave Recorder for speech-to-text
implementation("com.github.squti:Android-Wave-Recorder:2.1.0")

// Koin: dependency injection
implementation(libs.koin.android)
implementation(libs.koin.annotations)
implementation(libs.koin.androidx.compose)
implementation(libs.androidx.ui.text.google.fonts)
implementation(libs.androidx.compose.foundation)
ksp(libs.koin.ksp.compiler)

// compose-markdown: Markdown rendering in Compose
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright (C) 2024 Shubham Panchal
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.shubham0204.smollmandroid.data

import android.content.Context
import org.koin.core.annotation.Single

@Single
class PreferencesManager(context: Context) {
private val prefs = context.getSharedPreferences("smolchat_prefs", Context.MODE_PRIVATE)

var ttsEnabled: Boolean
get() = prefs.getBoolean("tts_enabled", false)
set(value) = prefs.edit().putBoolean("tts_enabled", value).apply()

var autoSubmitEnabled: Boolean
get() = prefs.getBoolean("auto_submit_enabled", false)
set(value) = prefs.edit().putBoolean("auto_submit_enabled", value).apply()

var autoSubmitDelayMs: Long
get() = prefs.getLong("auto_submit_delay_ms", 2000L)
set(value) = prefs.edit().putLong("auto_submit_delay_ms", value).apply()

var selectedWhisperModel: String
get() = prefs.getString("selected_whisper_model", DEFAULT_WHISPER_MODEL) ?: DEFAULT_WHISPER_MODEL
set(value) = prefs.edit().putString("selected_whisper_model", value).apply()

var sttLanguage: String
get() = prefs.getString("stt_language", DEFAULT_STT_LANGUAGE) ?: DEFAULT_STT_LANGUAGE
set(value) = prefs.edit().putString("stt_language", value).apply()

companion object {
const val DEFAULT_WHISPER_MODEL = "ggml-base.en.bin"
const val DEFAULT_STT_LANGUAGE = "en"

// Whisper supported languages with their display names
val SUPPORTED_LANGUAGES = listOf(
"en" to "English",
"de" to "German",
"fr" to "French",
"es" to "Spanish",
"it" to "Italian",
"pt" to "Portuguese",
"nl" to "Dutch",
"pl" to "Polish",
"ru" to "Russian",
"zh" to "Chinese",
"ja" to "Japanese",
"ko" to "Korean",
"ar" to "Arabic",
"hi" to "Hindi",
"tr" to "Turkish",
"uk" to "Ukrainian",
"cs" to "Czech",
"sv" to "Swedish",
"auto" to "Auto-detect",
)
}
}
Loading