Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Add on-device bookmark transcription

Barnabas2e0f06786c18
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/AudioWindowExtractor.kt b/android/app/src/main/kotlin/com/barnabas/absorb/AudioWindowExtractor.kt
new file mode 100644
index 00000000..309b3f50
--- /dev/null
+++ b/android/app/src/main/kotlin/com/barnabas/absorb/AudioWindowExtractor.kt
@@ -0,0 +1,214 @@
+package com.barnabas.absorb
+
+import android.media.MediaCodec
+import android.media.MediaExtractor
+import android.media.MediaFormat
+import android.util.Log
+import java.io.File
+import java.io.RandomAccessFile
+import java.nio.ByteBuffer
+import java.nio.ByteOrder
+
+/**
+ * Decodes a time window of a compressed audio file into the 16kHz mono 16-bit
+ * PCM WAV that whisper.cpp requires - using only the platform MediaCodec stack,
+ * so no ffmpeg ships in the app. Used by the opt-in bookmark transcription
+ * feature. Runs off the main thread (the caller spawns a worker).
+ */
+object AudioWindowExtractor {
+ private const val TAG = "AbsorbTranscribe"
+ private const val TARGET_RATE = 16000
+ private const val DEQUEUE_TIMEOUT_US = 10_000L
+
+ /** Boxing-free growable float buffer (a 30s 44.1kHz window is ~1.3M floats). */
+ private class FloatBuf(initial: Int) {
+ var data = FloatArray(initial.coerceAtLeast(1024))
+ var size = 0
+ fun add(v: Float) {
+ if (size == data.size) data = data.copyOf(size * 2)
+ data[size++] = v
+ }
+ operator fun get(i: Int) = data[i]
+ }
+
+ fun extractWav(
+ sourcePath: String,
+ startSeconds: Double,
+ durationSeconds: Double,
+ outPath: String,
+ ): Boolean {
+ val extractor = MediaExtractor()
+ var codec: MediaCodec? = null
+ try {
+ extractor.setDataSource(sourcePath)
+ val trackIndex = selectAudioTrack(extractor)
+ if (trackIndex < 0) {
+ Log.e(TAG, "No audio track in $sourcePath")
+ return false
+ }
+ extractor.selectTrack(trackIndex)
+ val inputFormat = extractor.getTrackFormat(trackIndex)
+ val mime = inputFormat.getString(MediaFormat.KEY_MIME) ?: return false
+ val srcRate = inputFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE)
+ val srcChannels = if (inputFormat.containsKey(MediaFormat.KEY_CHANNEL_COUNT))
+ inputFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT) else 1
+
+ val startUs = (startSeconds * 1_000_000L).toLong()
+ val durationUs = (durationSeconds * 1_000_000L).toLong()
+ extractor.seekTo(startUs, MediaExtractor.SEEK_TO_CLOSEST_SYNC)
+
+ codec = MediaCodec.createDecoderByType(mime)
+ codec.configure(inputFormat, null, null, 0)
+ codec.start()
+
+ val info = MediaCodec.BufferInfo()
+ var sawInputEOS = false
+ var sawOutputEOS = false
+ var outRate = srcRate
+ var outChannels = srcChannels
+ // AudioFormat.ENCODING_PCM_16BIT == 2, ENCODING_PCM_FLOAT == 4
+ var pcmEncoding = if (inputFormat.containsKey(MediaFormat.KEY_PCM_ENCODING))
+ inputFormat.getInteger(MediaFormat.KEY_PCM_ENCODING) else 2
+
+ val mono = FloatBuf((srcRate * durationSeconds).toInt())
+ var firstSampleUs = -1L
+ var collectedUs = 0L
+
+ while (!sawOutputEOS) {
+ if (!sawInputEOS) {
+ val inIndex = codec.dequeueInputBuffer(DEQUEUE_TIMEOUT_US)
+ if (inIndex >= 0) {
+ val inBuf = codec.getInputBuffer(inIndex)!!
+ val sampleSize = extractor.readSampleData(inBuf, 0)
+ if (sampleSize < 0) {
+ codec.queueInputBuffer(inIndex, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM)
+ sawInputEOS = true
+ } else {
+ codec.queueInputBuffer(inIndex, 0, sampleSize, extractor.sampleTime, 0)
+ extractor.advance()
+ }
+ }
+ }
+
+ val outIndex = codec.dequeueOutputBuffer(info, DEQUEUE_TIMEOUT_US)
+ if (outIndex == MediaCodec.INFO_OUTPUT_FORMAT_CHANGED) {
+ val of = codec.outputFormat
+ if (of.containsKey(MediaFormat.KEY_SAMPLE_RATE)) outRate = of.getInteger(MediaFormat.KEY_SAMPLE_RATE)
+ if (of.containsKey(MediaFormat.KEY_CHANNEL_COUNT)) outChannels = of.getInteger(MediaFormat.KEY_CHANNEL_COUNT)
+ if (of.containsKey(MediaFormat.KEY_PCM_ENCODING)) pcmEncoding = of.getInteger(MediaFormat.KEY_PCM_ENCODING)
+ } else if (outIndex >= 0) {
+ val outBuf = codec.getOutputBuffer(outIndex)
+ if (outBuf != null && info.size > 0) {
+ if (firstSampleUs < 0) firstSampleUs = info.presentationTimeUs
+ appendMono(outBuf, info, outChannels, pcmEncoding, mono)
+ collectedUs = info.presentationTimeUs - firstSampleUs
+ }
+ codec.releaseOutputBuffer(outIndex, false)
+ if (info.flags and MediaCodec.BUFFER_FLAG_END_OF_STREAM != 0) sawOutputEOS = true
+ if (durationUs > 0 && collectedUs >= durationUs) sawOutputEOS = true
+ }
+ }
+
+ if (mono.size == 0) {
+ Log.e(TAG, "No PCM decoded from $sourcePath")
+ return false
+ }
+ val resampled = resampleTo16k(mono, outRate)
+ writeWav(outPath, resampled)
+ Log.d(TAG, "extractWav ok: ${resampled.size} samples @16k -> $outPath")
+ return true
+ } catch (e: Exception) {
+ Log.e(TAG, "extractWav failed: ${e.message}", e)
+ return false
+ } finally {
+ try { codec?.stop() } catch (_: Exception) {}
+ try { codec?.release() } catch (_: Exception) {}
+ try { extractor.release() } catch (_: Exception) {}
+ }
+ }
+
+ private fun selectAudioTrack(extractor: MediaExtractor): Int {
+ for (i in 0 until extractor.trackCount) {
+ val mime = extractor.getTrackFormat(i).getString(MediaFormat.KEY_MIME) ?: continue
+ if (mime.startsWith("audio/")) return i
+ }
+ return -1
+ }
+
+ /** Append decoded frames, downmixing all channels to a single mono float. */
+ private fun appendMono(buf: ByteBuffer, info: MediaCodec.BufferInfo, channels: Int, pcmEncoding: Int, out: FloatBuf) {
+ buf.position(info.offset)
+ buf.limit(info.offset + info.size)
+ val ch = if (channels <= 0) 1 else channels
+ if (pcmEncoding == 4) { // ENCODING_PCM_FLOAT
+ val fb = buf.order(ByteOrder.nativeOrder()).asFloatBuffer()
+ val frames = fb.remaining() / ch
+ for (f in 0 until frames) {
+ var sum = 0f
+ for (c in 0 until ch) sum += fb.get()
+ out.add(sum / ch)
+ }
+ } else { // 16-bit PCM
+ val sb = buf.order(ByteOrder.LITTLE_ENDIAN).asShortBuffer()
+ val frames = sb.remaining() / ch
+ for (f in 0 until frames) {
+ var sum = 0
+ for (c in 0 until ch) sum += sb.get().toInt()
+ out.add((sum.toFloat() / ch) / 32768f)
+ }
+ }
+ }
+
+ /**
+ * Area-average resampler to 16kHz. Averaging over the source window each
+ * output sample spans acts as a crude anti-alias low-pass for downsampling,
+ * which is plenty for speech recognition. Passthrough when already 16kHz.
+ */
+ private fun resampleTo16k(src: FloatBuf, srcRate: Int): FloatArray {
+ if (srcRate == TARGET_RATE) return src.data.copyOf(src.size)
+ val ratio = srcRate.toDouble() / TARGET_RATE
+ val outLen = (src.size / ratio).toInt().coerceAtLeast(1)
+ val out = FloatArray(outLen)
+ for (n in 0 until outLen) {
+ val startIdx = (n * ratio).toInt().coerceIn(0, src.size - 1)
+ val endIdx = ((n + 1) * ratio).toInt().coerceIn(startIdx, src.size - 1)
+ var sum = 0f
+ var count = 0
+ var i = startIdx
+ while (i <= endIdx) { sum += src[i]; count++; i++ }
+ out[n] = if (count > 0) sum / count else src[startIdx]
+ }
+ return out
+ }
+
+ private fun writeWav(path: String, samples: FloatArray) {
+ val dataSize = samples.size * 2
+ val file = File(path)
+ file.parentFile?.mkdirs()
+ RandomAccessFile(file, "rw").use { raf ->
+ raf.setLength(0)
+ val header = ByteBuffer.allocate(44).order(ByteOrder.LITTLE_ENDIAN)
+ header.put("RIFF".toByteArray(Charsets.US_ASCII))
+ header.putInt(36 + dataSize)
+ header.put("WAVE".toByteArray(Charsets.US_ASCII))
+ header.put("fmt ".toByteArray(Charsets.US_ASCII))
+ header.putInt(16) // PCM fmt chunk size
+ header.putShort(1) // audio format = PCM
+ header.putShort(1) // channels = mono
+ header.putInt(TARGET_RATE) // sample rate
+ header.putInt(TARGET_RATE * 2) // byte rate = rate * channels * bytesPerSample
+ header.putShort(2) // block align = channels * bytesPerSample
+ header.putShort(16) // bits per sample
+ header.put("data".toByteArray(Charsets.US_ASCII))
+ header.putInt(dataSize)
+ raf.write(header.array())
+
+ val pcm = ByteBuffer.allocate(dataSize).order(ByteOrder.LITTLE_ENDIAN)
+ for (s in samples) {
+ val clamped = if (s > 1f) 1f else if (s < -1f) -1f else s
+ pcm.putShort((clamped * 32767f).toInt().toShort())
+ }
+ raf.write(pcm.array())
+ }
+ }
+}
diff --git a/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt b/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt
index 2f43df22..892d3b38 100644
--- a/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt
+++ b/android/app/src/main/kotlin/com/barnabas/absorb/MainActivity.kt
@@ -15,6 +15,8 @@ import android.media.audiofx.LoudnessEnhancer
import android.media.audiofx.Virtualizer
import android.os.Build
import android.os.Environment
+import android.os.Handler
+import android.os.Looper
import android.os.StatFs
import android.util.Log
@@ -165,6 +167,35 @@ class MainActivity : AudioServiceActivity() {
}
}
+ // On-device bookmark transcription: decode a window of a downloaded
+ // audio file into 16kHz mono WAV for Whisper. Heavy work runs on a
+ // worker thread; the result is posted back on the main thread.
+ MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "com.barnabas.absorb/transcription")
+ .setMethodCallHandler { call, result ->
+ when (call.method) {
+ "extractWav" -> {
+ val sourcePath = call.argument<String>("sourcePath")
+ val outPath = call.argument<String>("outPath")
+ val startSeconds = call.argument<Double>("startSeconds") ?: 0.0
+ val durationSeconds = call.argument<Double>("durationSeconds") ?: 0.0
+ if (sourcePath == null || outPath == null) {
+ result.error("ARGS", "sourcePath and outPath are required", null)
+ } else {
+ Thread {
+ val ok = try {
+ AudioWindowExtractor.extractWav(sourcePath, startSeconds, durationSeconds, outPath)
+ } catch (e: Exception) {
+ Log.e(TAG, "extractWav crashed: ${e.message}")
+ false
+ }
+ Handler(Looper.getMainLooper()).post { result.success(ok) }
+ }.start()
+ }
+ }
+ else -> result.notImplemented()
+ }
+ }
+
volumeKeysChannel = MethodChannel(
flutterEngine.dartExecutor.binaryMessenger, "com.absorb.volume_keys")
volumeKeysChannel?.setMethodCallHandler { call, result ->
diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index 09efea40..f60d55b2 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -4,6 +4,7 @@ import Flutter
import UIKit
import AVFoundation
import AVKit
+import CoreMedia
import MediaPlayer
import just_audio
@@ -455,6 +456,32 @@ let flutterEngine = FlutterEngine(name: "SharedEngine", project: nil, allowHeadl
result(true)
}
+ // On-device bookmark transcription: decode a window of a downloaded audio
+ // file into 16kHz mono WAV for Whisper. AVAssetReader does the resample +
+ // downmix for us; no ffmpeg ships in the app.
+ let transcriptionChannel = FlutterMethodChannel(name: "com.barnabas.absorb/transcription",
+ binaryMessenger: messenger)
+ transcriptionChannel.setMethodCallHandler { (call, result) in
+ switch call.method {
+ case "extractWav":
+ let args = call.arguments as? [String: Any]
+ guard let sourcePath = args?["sourcePath"] as? String,
+ let outPath = args?["outPath"] as? String else {
+ result(FlutterError(code: "ARGS", message: "sourcePath and outPath are required", details: nil))
+ return
+ }
+ let start = (args?["startSeconds"] as? Double) ?? 0
+ let dur = (args?["durationSeconds"] as? Double) ?? 0
+ DispatchQueue.global(qos: .userInitiated).async {
+ let ok = AudioWindowExtractor.extractWav(
+ sourcePath: sourcePath, startSeconds: start, durationSeconds: dur, outPath: outPath)
+ DispatchQueue.main.async { result(ok) }
+ }
+ default:
+ result(FlutterMethodNotImplemented)
+ }
+ }
+
let widgetChannel = FlutterMethodChannel(name: "com.absorb.widget",
binaryMessenger: messenger)
self.widgetChannel = widgetChannel
@@ -752,3 +779,107 @@ private final class VolumeKeyWatcher {
slider.value = value
}
}
+/// Decodes a time window of a compressed audio file into the 16kHz mono 16-bit
+/// PCM WAV that whisper.cpp requires. AVAssetReader performs the sample-rate
+/// conversion and downmix via its output settings, so no ffmpeg is needed.
+/// Used by the opt-in bookmark transcription feature.
+enum AudioWindowExtractor {
+ static func extractWav(sourcePath: String, startSeconds: Double, durationSeconds: Double, outPath: String) -> Bool {
+ let asset = AVURLAsset(url: URL(fileURLWithPath: sourcePath))
+ guard let track = asset.tracks(withMediaType: .audio).first else {
+ NSLog("[Transcribe] no audio track in %@", sourcePath)
+ return false
+ }
+
+ let reader: AVAssetReader
+ do {
+ reader = try AVAssetReader(asset: asset)
+ } catch {
+ NSLog("[Transcribe] reader init failed: %@", error.localizedDescription)
+ return false
+ }
+
+ let start = CMTime(seconds: max(0, startSeconds), preferredTimescale: 1000)
+ let dur = CMTime(seconds: max(0, durationSeconds), preferredTimescale: 1000)
+ reader.timeRange = CMTimeRange(start: start, duration: dur)
+
+ let settings: [String: Any] = [
+ AVFormatIDKey: kAudioFormatLinearPCM,
+ AVSampleRateKey: 16000,
+ AVNumberOfChannelsKey: 1,
+ AVLinearPCMBitDepthKey: 16,
+ AVLinearPCMIsFloatKey: false,
+ AVLinearPCMIsBigEndianKey: false,
+ AVLinearPCMIsNonInterleaved: false,
+ ]
+ let output = AVAssetReaderTrackOutput(track: track, outputSettings: settings)
+ output.alwaysCopiesSampleData = false
+ guard reader.canAdd(output) else { return false }
+ reader.add(output)
+ guard reader.startReading() else {
+ NSLog("[Transcribe] startReading failed: %@", reader.error?.localizedDescription ?? "nil")
+ return false
+ }
+
+ var pcm = Data()
+ while reader.status == .reading {
+ guard let sample = output.copyNextSampleBuffer() else { break }
+ if let block = CMSampleBufferGetDataBuffer(sample) {
+ let length = CMBlockBufferGetDataLength(block)
+ if length > 0 {
+ var chunk = Data(count: length)
+ chunk.withUnsafeMutableBytes { (ptr: UnsafeMutableRawBufferPointer) in
+ if let base = ptr.baseAddress {
+ _ = CMBlockBufferCopyDataBytes(block, atOffset: 0, dataLength: length, destination: base)
+ }
+ }
+ pcm.append(chunk)
+ }
+ }
+ CMSampleBufferInvalidate(sample)
+ }
+
+ if reader.status == .failed {
+ NSLog("[Transcribe] reader failed: %@", reader.error?.localizedDescription ?? "nil")
+ return false
+ }
+ if pcm.isEmpty { return false }
+ return writeWav(path: outPath, pcm16le: pcm, sampleRate: 16000)
+ }
+
+ private static func writeWav(path: String, pcm16le: Data, sampleRate: Int) -> Bool {
+ let channels = 1
+ let bitsPerSample = 16
+ let byteRate = sampleRate * channels * bitsPerSample / 8
+ let blockAlign = channels * bitsPerSample / 8
+ let dataSize = pcm16le.count
+
+ var header = Data()
+ func appendU32(_ v: UInt32) { var x = v.littleEndian; header.append(Data(bytes: &x, count: 4)) }
+ func appendU16(_ v: UInt16) { var x = v.littleEndian; header.append(Data(bytes: &x, count: 2)) }
+
+ header.append("RIFF".data(using: .ascii)!)
+ appendU32(UInt32(36 + dataSize))
+ header.append("WAVE".data(using: .ascii)!)
+ header.append("fmt ".data(using: .ascii)!)
+ appendU32(16) // PCM fmt chunk size
+ appendU16(1) // audio format = PCM
+ appendU16(UInt16(channels))
+ appendU32(UInt32(sampleRate))
+ appendU32(UInt32(byteRate))
+ appendU16(UInt16(blockAlign))
+ appendU16(UInt16(bitsPerSample))
+ header.append("data".data(using: .ascii)!)
+ appendU32(UInt32(dataSize))
+
+ var out = header
+ out.append(pcm16le)
+ do {
+ try out.write(to: URL(fileURLWithPath: path))
+ return true
+ } catch {
+ NSLog("[Transcribe] wav write failed: %@", error.localizedDescription)
+ return false
+ }
+ }
+}
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index 4d6f868e..64b98490 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -4709,5 +4709,32 @@
"placeholders": {
"query": {"type": "String"}
}
- }
+ },
+ "transcriptionTitle": "Bookmark transcription",
+ "transcriptionAdvancedSubtitle": "Turn the audio at a bookmark into text, on your device",
+ "transcriptionEnable": "Enable transcription",
+ "transcriptionEnableSubtitle": "Adds a Transcribe option to your bookmarks",
+ "transcriptionDisclaimer": "Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.",
+ "transcriptionNeedModelHint": "Download a model below to start transcribing.",
+ "transcriptionModelSection": "Model",
+ "transcriptionModelTiny": "Tiny",
+ "transcriptionModelTinyDesc": "Fastest, less accurate. About 31 MB.",
+ "transcriptionModelSmall": "Small",
+ "transcriptionModelSmallDesc": "Slower, more accurate. About 182 MB.",
+ "transcriptionDownload": "Download",
+ "transcriptionDownloadFailed": "Download failed. Check your connection and try again.",
+ "transcribe": "Transcribe",
+ "transcribing": "Transcribing...",
+ "transcriptionResultTitle": "Transcript",
+ "transcriptionSaveToNote": "Save to note",
+ "transcriptionSavedToNote": "Saved to bookmark note",
+ "transcriptionDisabledHint": "Turn on bookmark transcription in Settings, under Advanced.",
+ "transcriptionNoModelDownloaded": "Download a transcription model in Settings first.",
+ "transcriptionNotDownloadedBook": "Download this book first to transcribe its bookmarks.",
+ "transcriptionNoMetadataMsg": "Can't locate this spot in the download. Try re-downloading the book.",
+ "transcriptionBusyMsg": "Already transcribing something. Give it a moment.",
+ "transcriptionEmptyMsg": "No speech was found at this spot.",
+ "transcriptionFailedMsg": "Couldn't transcribe this spot. Please try again.",
+ "transcriptionPlaySnippet": "Listen",
+ "transcriptionPauseSnippet": "Pause"
}
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index 70be318c..13593933 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -14090,6 +14090,168 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'No matches for \"{query}\".'**
String readerSearchNoResults(String query);
+
+ /// No description provided for @transcriptionTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Bookmark transcription'**
+ String get transcriptionTitle;
+
+ /// No description provided for @transcriptionAdvancedSubtitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn the audio at a bookmark into text, on your device'**
+ String get transcriptionAdvancedSubtitle;
+
+ /// No description provided for @transcriptionEnable.
+ ///
+ /// In en, this message translates to:
+ /// **'Enable transcription'**
+ String get transcriptionEnable;
+
+ /// No description provided for @transcriptionEnableSubtitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Adds a Transcribe option to your bookmarks'**
+ String get transcriptionEnableSubtitle;
+
+ /// No description provided for @transcriptionDisclaimer.
+ ///
+ /// In en, this message translates to:
+ /// **'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.'**
+ String get transcriptionDisclaimer;
+
+ /// No description provided for @transcriptionNeedModelHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Download a model below to start transcribing.'**
+ String get transcriptionNeedModelHint;
+
+ /// No description provided for @transcriptionModelSection.
+ ///
+ /// In en, this message translates to:
+ /// **'Model'**
+ String get transcriptionModelSection;
+
+ /// No description provided for @transcriptionModelTiny.
+ ///
+ /// In en, this message translates to:
+ /// **'Tiny'**
+ String get transcriptionModelTiny;
+
+ /// No description provided for @transcriptionModelTinyDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Fastest, less accurate. About 31 MB.'**
+ String get transcriptionModelTinyDesc;
+
+ /// No description provided for @transcriptionModelSmall.
+ ///
+ /// In en, this message translates to:
+ /// **'Small'**
+ String get transcriptionModelSmall;
+
+ /// No description provided for @transcriptionModelSmallDesc.
+ ///
+ /// In en, this message translates to:
+ /// **'Slower, more accurate. About 182 MB.'**
+ String get transcriptionModelSmallDesc;
+
+ /// No description provided for @transcriptionDownload.
+ ///
+ /// In en, this message translates to:
+ /// **'Download'**
+ String get transcriptionDownload;
+
+ /// No description provided for @transcriptionDownloadFailed.
+ ///
+ /// In en, this message translates to:
+ /// **'Download failed. Check your connection and try again.'**
+ String get transcriptionDownloadFailed;
+
+ /// No description provided for @transcribe.
+ ///
+ /// In en, this message translates to:
+ /// **'Transcribe'**
+ String get transcribe;
+
+ /// No description provided for @transcribing.
+ ///
+ /// In en, this message translates to:
+ /// **'Transcribing...'**
+ String get transcribing;
+
+ /// No description provided for @transcriptionResultTitle.
+ ///
+ /// In en, this message translates to:
+ /// **'Transcript'**
+ String get transcriptionResultTitle;
+
+ /// No description provided for @transcriptionSaveToNote.
+ ///
+ /// In en, this message translates to:
+ /// **'Save to note'**
+ String get transcriptionSaveToNote;
+
+ /// No description provided for @transcriptionSavedToNote.
+ ///
+ /// In en, this message translates to:
+ /// **'Saved to bookmark note'**
+ String get transcriptionSavedToNote;
+
+ /// No description provided for @transcriptionDisabledHint.
+ ///
+ /// In en, this message translates to:
+ /// **'Turn on bookmark transcription in Settings, under Advanced.'**
+ String get transcriptionDisabledHint;
+
+ /// No description provided for @transcriptionNoModelDownloaded.
+ ///
+ /// In en, this message translates to:
+ /// **'Download a transcription model in Settings first.'**
+ String get transcriptionNoModelDownloaded;
+
+ /// No description provided for @transcriptionNotDownloadedBook.
+ ///
+ /// In en, this message translates to:
+ /// **'Download this book first to transcribe its bookmarks.'**
+ String get transcriptionNotDownloadedBook;
+
+ /// No description provided for @transcriptionNoMetadataMsg.
+ ///
+ /// In en, this message translates to:
+ /// **'Can\'t locate this spot in the download. Try re-downloading the book.'**
+ String get transcriptionNoMetadataMsg;
+
+ /// No description provided for @transcriptionBusyMsg.
+ ///
+ /// In en, this message translates to:
+ /// **'Already transcribing something. Give it a moment.'**
+ String get transcriptionBusyMsg;
+
+ /// No description provided for @transcriptionEmptyMsg.
+ ///
+ /// In en, this message translates to:
+ /// **'No speech was found at this spot.'**
+ String get transcriptionEmptyMsg;
+
+ /// No description provided for @transcriptionFailedMsg.
+ ///
+ /// In en, this message translates to:
+ /// **'Couldn\'t transcribe this spot. Please try again.'**
+ String get transcriptionFailedMsg;
+
+ /// No description provided for @transcriptionPlaySnippet.
+ ///
+ /// In en, this message translates to:
+ /// **'Listen'**
+ String get transcriptionPlaySnippet;
+
+ /// No description provided for @transcriptionPauseSnippet.
+ ///
+ /// In en, this message translates to:
+ /// **'Pause'**
+ String get transcriptionPauseSnippet;
}
class _AppLocalizationsDelegate
diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart
index e119a168..ec7c26b5 100644
--- a/lib/l10n/app_localizations_de.dart
+++ b/lib/l10n/app_localizations_de.dart
@@ -8275,4 +8275,98 @@ class AppLocalizationsDe extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'Keine Treffer für \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dart
index 422c9eea..69045906 100644
--- a/lib/l10n/app_localizations_el.dart
+++ b/lib/l10n/app_localizations_el.dart
@@ -8163,4 +8163,98 @@ class AppLocalizationsEl extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 36470be9..ed7bf266 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -8163,4 +8163,98 @@ class AppLocalizationsEn extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart
index fdfe2185..23651f97 100644
--- a/lib/l10n/app_localizations_es.dart
+++ b/lib/l10n/app_localizations_es.dart
@@ -8165,4 +8165,98 @@ class AppLocalizationsEs extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart
index 5044a808..a9dba443 100644
--- a/lib/l10n/app_localizations_fr.dart
+++ b/lib/l10n/app_localizations_fr.dart
@@ -8212,4 +8212,98 @@ class AppLocalizationsFr extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart
index 92b70857..ee4dae92 100644
--- a/lib/l10n/app_localizations_it.dart
+++ b/lib/l10n/app_localizations_it.dart
@@ -8163,4 +8163,98 @@ class AppLocalizationsIt extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart
index c0549e78..e3abe9ab 100644
--- a/lib/l10n/app_localizations_ja.dart
+++ b/lib/l10n/app_localizations_ja.dart
@@ -8163,4 +8163,98 @@ class AppLocalizationsJa extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dart
index 268a86c0..5cb5c99a 100644
--- a/lib/l10n/app_localizations_no.dart
+++ b/lib/l10n/app_localizations_no.dart
@@ -8163,4 +8163,98 @@ class AppLocalizationsNo extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart
index 7f1f86a0..c2fa5293 100644
--- a/lib/l10n/app_localizations_pt.dart
+++ b/lib/l10n/app_localizations_pt.dart
@@ -8163,4 +8163,98 @@ class AppLocalizationsPt extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dart
index b74757fe..16321e12 100644
--- a/lib/l10n/app_localizations_ro.dart
+++ b/lib/l10n/app_localizations_ro.dart
@@ -8163,4 +8163,98 @@ class AppLocalizationsRo extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart
index e9c9b739..998d21e8 100644
--- a/lib/l10n/app_localizations_ru.dart
+++ b/lib/l10n/app_localizations_ru.dart
@@ -8168,4 +8168,98 @@ class AppLocalizationsRu extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index e285b893..ac1d600d 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -8071,4 +8071,98 @@ class AppLocalizationsZh extends AppLocalizations {
String readerSearchNoResults(String query) {
return 'No matches for \"$query\".';
}
+
+ @override
+ String get transcriptionTitle => 'Bookmark transcription';
+
+ @override
+ String get transcriptionAdvancedSubtitle =>
+ 'Turn the audio at a bookmark into text, on your device';
+
+ @override
+ String get transcriptionEnable => 'Enable transcription';
+
+ @override
+ String get transcriptionEnableSubtitle =>
+ 'Adds a Transcribe option to your bookmarks';
+
+ @override
+ String get transcriptionDisclaimer =>
+ 'Runs entirely on your device, nothing is sent anywhere. It uses extra battery and processing while it works, and only downloaded books can be transcribed.';
+
+ @override
+ String get transcriptionNeedModelHint =>
+ 'Download a model below to start transcribing.';
+
+ @override
+ String get transcriptionModelSection => 'Model';
+
+ @override
+ String get transcriptionModelTiny => 'Tiny';
+
+ @override
+ String get transcriptionModelTinyDesc =>
+ 'Fastest, less accurate. About 31 MB.';
+
+ @override
+ String get transcriptionModelSmall => 'Small';
+
+ @override
+ String get transcriptionModelSmallDesc =>
+ 'Slower, more accurate. About 182 MB.';
+
+ @override
+ String get transcriptionDownload => 'Download';
+
+ @override
+ String get transcriptionDownloadFailed =>
+ 'Download failed. Check your connection and try again.';
+
+ @override
+ String get transcribe => 'Transcribe';
+
+ @override
+ String get transcribing => 'Transcribing...';
+
+ @override
+ String get transcriptionResultTitle => 'Transcript';
+
+ @override
+ String get transcriptionSaveToNote => 'Save to note';
+
+ @override
+ String get transcriptionSavedToNote => 'Saved to bookmark note';
+
+ @override
+ String get transcriptionDisabledHint =>
+ 'Turn on bookmark transcription in Settings, under Advanced.';
+
+ @override
+ String get transcriptionNoModelDownloaded =>
+ 'Download a transcription model in Settings first.';
+
+ @override
+ String get transcriptionNotDownloadedBook =>
+ 'Download this book first to transcribe its bookmarks.';
+
+ @override
+ String get transcriptionNoMetadataMsg =>
+ 'Can\'t locate this spot in the download. Try re-downloading the book.';
+
+ @override
+ String get transcriptionBusyMsg =>
+ 'Already transcribing something. Give it a moment.';
+
+ @override
+ String get transcriptionEmptyMsg => 'No speech was found at this spot.';
+
+ @override
+ String get transcriptionFailedMsg =>
+ 'Couldn\'t transcribe this spot. Please try again.';
+
+ @override
+ String get transcriptionPlaySnippet => 'Listen';
+
+ @override
+ String get transcriptionPauseSnippet => 'Pause';
}
diff --git a/lib/screens/bookmarks_screen.dart b/lib/screens/bookmarks_screen.dart
index 0c637c9f..6f9275aa 100644
--- a/lib/screens/bookmarks_screen.dart
+++ b/lib/screens/bookmarks_screen.dart
@@ -1,3 +1,4 @@
+import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:cached_network_image/cached_network_image.dart';
diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart
index 9994dc77..d021b289 100644
--- a/lib/screens/settings_screen.dart
+++ b/lib/screens/settings_screen.dart
@@ -30,6 +30,7 @@ import '../screens/backup_sync_screen.dart';
import '../services/settings_sync_service.dart';
import '../screens/change_password_screen.dart';
import '../screens/auth_sessions_screen.dart';
+import '../screens/transcription_settings_screen.dart';
import '../main.dart' show applyThemeMode, applyTrustAllCerts, applyFlatBackground, applyColorSource, applyManualSeed, applyGradientIntensity, applyUseColorEverywhere, applyOrientationLock, localeNotifier, flatNotifier, gradientIntensityNotifier, snappyTransitionsNotifier;
import '../services/wording.dart';
import '../widgets/absorb_page_header.dart';
@@ -3845,6 +3846,16 @@ class _SettingsScreenState extends State<SettingsScreen> {
trailing: Icon(Icons.chevron_right_rounded, color: cs.onSurfaceVariant.withValues(alpha: 0.5)),
onTap: _openRmabSheetFromSettings,
),
+ const Divider(height: 1, indent: 16, endIndent: 16),
+ ListTile(
+ leading: Icon(Icons.record_voice_over_rounded, color: cs.primary),
+ title: Text(l.transcriptionTitle),
+ subtitle: Text(l.transcriptionAdvancedSubtitle,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ trailing: Icon(Icons.chevron_right_rounded, color: cs.onSurfaceVariant.withValues(alpha: 0.5)),
+ onTap: () => Navigator.push(context, MaterialPageRoute(
+ builder: (_) => const TranscriptionSettingsScreen())),
+ ),
],
),
const SizedBox(height: 16),
diff --git a/lib/screens/transcription_settings_screen.dart b/lib/screens/transcription_settings_screen.dart
new file mode 100644
index 00000000..2c6866c6
--- /dev/null
+++ b/lib/screens/transcription_settings_screen.dart
@@ -0,0 +1,229 @@
+import 'package:flutter/material.dart';
+import '../l10n/app_localizations.dart';
+import '../services/player_settings.dart';
+import '../services/transcription_service.dart';
+
+/// Advanced > Bookmark transcription settings: opt-in toggle and on-device
+/// Whisper model management (download / pick / delete). Everything here runs
+/// locally - no audio or text ever leaves the device.
+class TranscriptionSettingsScreen extends StatefulWidget {
+ const TranscriptionSettingsScreen({super.key});
+
+ @override
+ State<TranscriptionSettingsScreen> createState() =>
+ _TranscriptionSettingsScreenState();
+}
+
+class _TranscriptionSettingsScreenState
+ extends State<TranscriptionSettingsScreen> {
+ bool _loaded = false;
+ bool _enabled = false;
+ String _model = 'tiny';
+ final Map<TranscriptionModelSize, bool> _downloaded = {};
+ TranscriptionModelSize? _downloading;
+ double _progress = 0;
+
+ @override
+ void initState() {
+ super.initState();
+ _load();
+ }
+
+ Future<void> _load() async {
+ _enabled = await PlayerSettings.getTranscriptionEnabled();
+ _model = await PlayerSettings.getTranscriptionModel();
+ for (final s in TranscriptionModelSize.values) {
+ _downloaded[s] = await TranscriptionService.instance.isModelDownloaded(s);
+ }
+ if (mounted) setState(() => _loaded = true);
+ }
+
+ Future<void> _setEnabled(bool v) async {
+ setState(() => _enabled = v);
+ await PlayerSettings.setTranscriptionEnabled(v);
+ }
+
+ Future<void> _selectModel(TranscriptionModelSize size) async {
+ final value = size == TranscriptionModelSize.small ? 'small' : 'tiny';
+ setState(() => _model = value);
+ await PlayerSettings.setTranscriptionModel(value);
+ }
+
+ Future<void> _download(TranscriptionModelSize size) async {
+ final l = AppLocalizations.of(context)!;
+ setState(() {
+ _downloading = size;
+ _progress = 0;
+ });
+ try {
+ await TranscriptionService.instance.downloadModel(size, onProgress: (p) {
+ if (mounted) setState(() => _progress = p);
+ });
+ if (mounted) {
+ setState(() {
+ _downloaded[size] = true;
+ _downloading = null;
+ });
+ }
+ } catch (_) {
+ if (mounted) {
+ setState(() => _downloading = null);
+ // Refresh in case a partial file was left behind.
+ _downloaded[size] = await TranscriptionService.instance.isModelDownloaded(size);
+ if (!mounted) return;
+ ScaffoldMessenger.of(context).showSnackBar(SnackBar(
+ content: Text(l.transcriptionDownloadFailed),
+ behavior: SnackBarBehavior.floating,
+ ));
+ }
+ }
+ }
+
+ void _cancelDownload() {
+ TranscriptionService.instance.cancelActiveDownload();
+ }
+
+ Future<void> _delete(TranscriptionModelSize size) async {
+ await TranscriptionService.instance.deleteModel(size);
+ if (mounted) setState(() => _downloaded[size] = false);
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final cs = Theme.of(context).colorScheme;
+ final tt = Theme.of(context).textTheme;
+ final l = AppLocalizations.of(context)!;
+
+ final anyDownloaded = _downloaded.values.any((d) => d);
+
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(l.transcriptionTitle),
+ ),
+ body: !_loaded
+ ? const Center(child: CircularProgressIndicator())
+ : ListView(
+ children: [
+ SwitchListTile(
+ title: Text(l.transcriptionEnable),
+ subtitle: Text(l.transcriptionEnableSubtitle,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ value: _enabled,
+ onChanged: _setEnabled,
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 4, 16, 12),
+ child: Container(
+ padding: const EdgeInsets.all(14),
+ decoration: BoxDecoration(
+ color: cs.surfaceContainerHigh,
+ borderRadius: BorderRadius.circular(12),
+ ),
+ child: Row(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Icon(Icons.lock_outline_rounded, size: 18, color: cs.primary),
+ const SizedBox(width: 10),
+ Expanded(
+ child: Text(
+ l.transcriptionDisclaimer,
+ style: tt.bodySmall
+ ?.copyWith(color: cs.onSurfaceVariant, height: 1.4),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ if (_enabled && !anyDownloaded)
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 0, 16, 8),
+ child: Text(
+ l.transcriptionNeedModelHint,
+ style: tt.bodySmall?.copyWith(color: cs.error),
+ ),
+ ),
+ const Divider(height: 1),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 16, 16, 4),
+ child: Text(l.transcriptionModelSection,
+ style: tt.titleSmall?.copyWith(color: cs.primary)),
+ ),
+ _modelTile(
+ size: TranscriptionModelSize.tiny,
+ label: l.transcriptionModelTiny,
+ desc: l.transcriptionModelTinyDesc,
+ cs: cs,
+ tt: tt,
+ l: l,
+ ),
+ _modelTile(
+ size: TranscriptionModelSize.small,
+ label: l.transcriptionModelSmall,
+ desc: l.transcriptionModelSmallDesc,
+ cs: cs,
+ tt: tt,
+ l: l,
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _modelTile({
+ required TranscriptionModelSize size,
+ required String label,
+ required String desc,
+ required ColorScheme cs,
+ required TextTheme tt,
+ required AppLocalizations l,
+ }) {
+ final isDownloaded = _downloaded[size] ?? false;
+ final isDownloading = _downloading == size;
+ final selected = (_model == 'small') == (size == TranscriptionModelSize.small);
+
+ Widget trailing;
+ if (isDownloading) {
+ trailing = Row(mainAxisSize: MainAxisSize.min, children: [
+ SizedBox(
+ width: 22,
+ height: 22,
+ child: CircularProgressIndicator(
+ strokeWidth: 2.5, value: _progress > 0 ? _progress : null),
+ ),
+ const SizedBox(width: 4),
+ IconButton(
+ icon: const Icon(Icons.close_rounded),
+ tooltip: l.cancel,
+ onPressed: _cancelDownload,
+ ),
+ ]);
+ } else if (isDownloaded) {
+ trailing = Row(mainAxisSize: MainAxisSize.min, children: [
+ Icon(Icons.check_circle_rounded, color: cs.primary, size: 20),
+ IconButton(
+ icon: Icon(Icons.delete_outline_rounded, color: cs.onSurfaceVariant),
+ tooltip: l.delete,
+ onPressed: () => _delete(size),
+ ),
+ ]);
+ } else {
+ trailing = TextButton.icon(
+ icon: const Icon(Icons.download_rounded, size: 18),
+ label: Text(l.transcriptionDownload),
+ onPressed: _downloading == null ? () => _download(size) : null,
+ );
+ }
+
+ return RadioListTile<bool>(
+ value: true,
+ groupValue: selected ? true : null,
+ onChanged: isDownloaded ? (_) => _selectModel(size) : null,
+ controlAffinity: ListTileControlAffinity.leading,
+ title: Text(label),
+ subtitle: Text(desc,
+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),
+ secondary: trailing,
+ );
+ }
+}
diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dart
index 4fdd4d14..2c5f786f 100644
--- a/lib/services/player_settings.dart
+++ b/lib/services/player_settings.dart
@@ -194,6 +194,31 @@ class PlayerSettings {
static Future<String> getBookmarkSort() => _get('bookmarkSort', 'newest');
static Future<void> setBookmarkSort(String value) => _set('bookmarkSort', value);
+ // On-device bookmark transcription (Whisper, opt-in). Stored globally
+ // (raw SharedPreferences, not per-account) because the downloaded Whisper
+ // model is shared across every profile on the device.
+
+ static Future<bool> getTranscriptionEnabled() async {
+ final prefs = await SharedPreferences.getInstance();
+ return prefs.getBool('transcriptionEnabled') ?? false;
+ }
+ static Future<void> setTranscriptionEnabled(bool value) async {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setBool('transcriptionEnabled', value);
+ _notify();
+ }
+
+ /// Which Whisper model the transcriber loads: 'tiny' (default) or 'small'.
+ static Future<String> getTranscriptionModel() async {
+ final prefs = await SharedPreferences.getInstance();
+ return prefs.getString('transcriptionModel') ?? 'tiny';
+ }
+ static Future<void> setTranscriptionModel(String value) async {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setString('transcriptionModel', value);
+ _notify();
+ }
+
// The dedicated Podcasts tab implies merged behavior: playback must survive
// the tab-driven library flips and the Absorbing tab must keep showing the
// playing item from either tab.
diff --git a/lib/services/transcription_service.dart b/lib/services/transcription_service.dart
new file mode 100644
index 00000000..63255183
--- /dev/null
+++ b/lib/services/transcription_service.dart
@@ -0,0 +1,365 @@
+import 'dart:async';
+import 'dart:convert';
+import 'dart:io';
+
+import 'package:flutter/foundation.dart';
+import 'package:flutter/services.dart';
+import 'package:path_provider/path_provider.dart';
+import 'package:whisper_ggml_plus/whisper_ggml_plus.dart';
+
+import 'download_service.dart';
+import 'player_settings.dart';
+
+/// On-device bookmark transcription using Whisper (whisper.cpp via
+/// whisper_ggml_plus). Opt-in, downloaded-books only for now.
+///
+/// This is the single seam between the app and the underlying speech engine.
+/// The UI and bookmark code only ever talk to [TranscriptionService] - the
+/// concrete engine (whisper_ggml_plus today, possibly sherpa-onnx forced
+/// alignment later for read-along) stays swappable behind it.
+///
+/// Audio is decoded to the 16kHz mono WAV Whisper requires by native code
+/// (Android MediaCodec / iOS AVAssetReader) - no ffmpeg ships in the app.
+
+enum TranscriptionModelSize { tiny, small }
+
+/// Static description of a downloadable model. We deliberately pull the q5_1
+/// quantized weights (roughly half the size, negligible accuracy loss) but
+/// save them under the *unquantized* filename whisper.cpp's loader expects, so
+/// [WhisperController] finds them. whisper.cpp loads quantized ggml transparently.
+class TranscriptionModelInfo {
+ const TranscriptionModelInfo({
+ required this.size,
+ required this.whisperModel,
+ required this.downloadUrl,
+ required this.fileName,
+ required this.approxBytes,
+ });
+
+ final TranscriptionModelSize size;
+ final WhisperModel whisperModel;
+ final String downloadUrl;
+ final String fileName;
+ final int approxBytes;
+
+ static const tiny = TranscriptionModelInfo(
+ size: TranscriptionModelSize.tiny,
+ whisperModel: WhisperModel.tiny,
+ downloadUrl:
+ 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-tiny-q5_1.bin',
+ fileName: 'ggml-tiny.bin',
+ approxBytes: 32 * 1024 * 1024, // ~31 MB
+ );
+
+ static const small = TranscriptionModelInfo(
+ size: TranscriptionModelSize.small,
+ whisperModel: WhisperModel.small,
+ downloadUrl:
+ 'https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-small-q5_1.bin',
+ fileName: 'ggml-small.bin',
+ approxBytes: 190 * 1024 * 1024, // ~182 MB
+ );
+
+ static TranscriptionModelInfo forSize(TranscriptionModelSize size) =>
+ size == TranscriptionModelSize.small ? small : tiny;
+
+ static TranscriptionModelInfo fromPref(String value) =>
+ value == 'small' ? small : tiny;
+}
+
+/// Why a transcription could not be produced. The UI maps these to localized,
+/// user-facing messages.
+enum TranscriptionError {
+ disabled,
+ modelMissing,
+ notDownloaded,
+ noMetadata,
+ extractFailed,
+ transcribeFailed,
+ busy,
+ empty,
+}
+
+class TranscriptionException implements Exception {
+ TranscriptionException(this.kind, [this.detail]);
+ final TranscriptionError kind;
+ final Object? detail;
+ @override
+ String toString() => 'TranscriptionException($kind${detail == null ? '' : ': $detail'})';
+}
+
+/// Resolve which downloaded track file contains [globalSeconds] and the offset
+/// within that track. Pure function so it can be unit-tested without any
+/// download state. [trackDurations] is index-aligned with the track file list.
+({int index, double offset}) mapGlobalToTrack(
+ List<double> trackDurations, double globalSeconds) {
+ var remaining = globalSeconds < 0 ? 0.0 : globalSeconds;
+ if (trackDurations.isEmpty) return (index: 0, offset: remaining);
+ for (var i = 0; i < trackDurations.length; i++) {
+ final d = trackDurations[i];
+ final isLast = i == trackDurations.length - 1;
+ if (remaining < d || isLast) {
+ final maxOffset = d > 0 ? d : remaining;
+ return (index: i, offset: remaining.clamp(0.0, maxOffset).toDouble());
+ }
+ remaining -= d;
+ }
+ return (index: trackDurations.length - 1, offset: 0);
+}
+
+class TranscriptionService {
+ TranscriptionService._();
+ static final TranscriptionService instance = TranscriptionService._();
+
+ static const _channel = MethodChannel('com.barnabas.absorb/transcription');
+
+ final WhisperController _whisper = WhisperController();
+
+ // How much audio to feed Whisper around a bookmark, and how far before the
+ // mark to start (so the clip captures the lead-in, not just what follows).
+ static const double _windowSeconds = 30.0;
+ static const double _leadSeconds = 3.0;
+
+ bool _busy = false;
+ bool _cancelDownload = false;
+
+ // Model management
+
+ Future<String> _modelDir() => WhisperController.getModelDir();
+
+ Future<File> _modelFile(TranscriptionModelInfo info) async {
+ final dir = await _modelDir();
+ return File('$dir${Platform.pathSeparator}${info.fileName}');
+ }
+
+ Future<bool> isModelDownloaded(TranscriptionModelSize size) async {
+ final file = await _modelFile(TranscriptionModelInfo.forSize(size));
+ return file.existsSync() && await file.length() > 0;
+ }
+
+ /// Stream the (quantized) model to disk with progress (0..1). Writes to a
+ /// `.part` file and renames on success so an interrupted download is never
+ /// mistaken for a complete model. Throws on HTTP error or cancellation.
+ Future<void> downloadModel(
+ TranscriptionModelSize size, {
+ void Function(double progress)? onProgress,
+ }) async {
+ _cancelDownload = false;
+ final info = TranscriptionModelInfo.forSize(size);
+ final file = await _modelFile(info);
+ await file.parent.create(recursive: true);
+ final part = File('${file.path}.part');
+
+ final client = HttpClient();
+ try {
+ final request = await client.getUrl(Uri.parse(info.downloadUrl));
+ final response = await request.close();
+ if (response.statusCode != 200) {
+ throw TranscriptionException(
+ TranscriptionError.modelMissing, 'HTTP ${response.statusCode}');
+ }
+ final total = response.contentLength > 0
+ ? response.contentLength
+ : info.approxBytes;
+ final sink = part.openWrite();
+ var received = 0;
+ try {
+ await for (final chunk in response) {
+ if (_cancelDownload) {
+ await sink.close();
+ if (part.existsSync()) await part.delete();
+ throw TranscriptionException(TranscriptionError.modelMissing, 'cancelled');
+ }
+ received += chunk.length;
+ sink.add(chunk);
+ onProgress?.call((received / total).clamp(0.0, 1.0));
+ }
+ await sink.flush();
+ await sink.close();
+ } catch (_) {
+ await sink.close().catchError((_) {});
+ if (part.existsSync()) await part.delete().catchError((_) => part);
+ rethrow;
+ }
+ if (file.existsSync()) await file.delete();
+ await part.rename(file.path);
+ onProgress?.call(1.0);
+ debugPrint('[Transcribe] Model ${info.fileName} downloaded (${received ~/ (1024 * 1024)} MB)');
+ } finally {
+ client.close(force: false);
+ }
+ }
+
+ void cancelActiveDownload() => _cancelDownload = true;
+
+ Future<void> deleteModel(TranscriptionModelSize size) async {
+ final file = await _modelFile(TranscriptionModelInfo.forSize(size));
+ if (file.existsSync()) await file.delete();
+ }
+
+ // Transcription
+
+ /// Can this book be transcribed right now? Only downloaded books are
+ /// supported (we need the local audio file to extract a window from).
+ bool canTranscribeBook(String itemId) =>
+ DownloadService().getLocalPaths(itemId)?.isNotEmpty ?? false;
+
+ /// Transcribe the audio around [positionSeconds] of [itemId]. Returns the
+ /// transcript text plus the path to the extracted 16kHz WAV clip, which the
+ /// caller can play back for review and MUST delete when finished. Throws
+ /// [TranscriptionException] on any failure so the UI can show a specific message.
+ Future<({String text, String audioPath})> transcribeAt({
+ required String itemId,
+ required double positionSeconds,
+ }) async {
+ if (!await PlayerSettings.getTranscriptionEnabled()) {
+ throw TranscriptionException(TranscriptionError.disabled);
+ }
+ if (_busy) throw TranscriptionException(TranscriptionError.busy);
+
+ final info = TranscriptionModelInfo.fromPref(
+ await PlayerSettings.getTranscriptionModel());
+ if (!await isModelDownloaded(info.size)) {
+ throw TranscriptionException(TranscriptionError.modelMissing);
+ }
+
+ final localPaths = DownloadService().getLocalPaths(itemId);
+ if (localPaths == null || localPaths.isEmpty) {
+ throw TranscriptionException(TranscriptionError.notDownloaded);
+ }
+
+ // Resolve which track file + offset the bookmark lands in.
+ final durations = _trackDurations(itemId);
+ final int trackIndex;
+ final double localOffset;
+ final double trackDuration;
+ final double gStart = (positionSeconds - _leadSeconds).clamp(0.0, double.infinity);
+ if (durations != null && durations.length == localPaths.length) {
+ final m = mapGlobalToTrack(durations, gStart);
+ trackIndex = m.index;
+ localOffset = m.offset;
+ trackDuration = durations[trackIndex];
+ } else if (localPaths.length == 1) {
+ // Single-file book: no per-track metadata needed.
+ trackIndex = 0;
+ localOffset = gStart;
+ trackDuration = double.infinity;
+ } else {
+ // Multi-file book but we can't map without durations.
+ throw TranscriptionException(TranscriptionError.noMetadata);
+ }
+
+ final sourcePath = localPaths[trackIndex];
+ if (!File(sourcePath).existsSync()) {
+ throw TranscriptionException(TranscriptionError.notDownloaded, sourcePath);
+ }
+
+ // Clamp the window so it never runs past the end of this track (v1 doesn't
+ // span file boundaries - a bookmark in the last few seconds of a track just
+ // gets a shorter clip).
+ final available = trackDuration.isFinite ? trackDuration - localOffset : _windowSeconds;
+ final window = available < _windowSeconds ? available : _windowSeconds;
+ if (window <= 0.5) {
+ throw TranscriptionException(TranscriptionError.extractFailed, 'window too short');
+ }
+
+ _busy = true;
+ String? wavPath;
+ try {
+ wavPath = await _extractWav(
+ sourcePath: sourcePath,
+ startSeconds: localOffset,
+ durationSeconds: window,
+ );
+ if (wavPath == null || !File(wavPath).existsSync()) {
+ throw TranscriptionException(TranscriptionError.extractFailed);
+ }
+
+ // NB: TranscribeResult isn't exported by the package, so let the type be
+ // inferred rather than naming it. `.transcription` is a (exported)
+ // WhisperTranscribeResponse whose `.text` is the full transcript.
+ final String text;
+ try {
+ final result = await _whisper.transcribe(
+ model: info.whisperModel,
+ audioPath: wavPath,
+ lang: 'auto',
+ convert: false, // we always hand it a ready 16kHz WAV
+ withTimestamps: false,
+ // Must be auto/enabled, NOT disabled: with disabled the package sends
+ // vad_model_path as JSON null and the native parser does .get<string>()
+ // on it, throwing "type must be string, but is null". auto makes the
+ // package extract its bundled Silero VAD model and pass a real path.
+ vadMode: WhisperVadMode.auto,
+ threads: _threads(),
+ );
+ text = (result?.transcription.text ?? '').trim();
+ } catch (e) {
+ if (e is TranscriptionException) rethrow;
+ throw TranscriptionException(TranscriptionError.transcribeFailed, e);
+ }
+ if (text.isEmpty) throw TranscriptionException(TranscriptionError.empty);
+ // Hand the extracted clip to the caller (for review playback). Ownership
+ // transfers, so null out wavPath to skip the finally-delete below.
+ final out = (text: text, audioPath: wavPath);
+ wavPath = null;
+ return out;
+ } finally {
+ _busy = false;
+ if (wavPath != null) {
+ try {
+ final f = File(wavPath);
+ if (f.existsSync()) await f.delete();
+ } catch (_) {}
+ }
+ }
+ }
+
+ bool get isBusy => _busy;
+
+ // Internals
+
+ int _threads() => (Platform.numberOfProcessors - 1).clamp(2, 6);
+
+ /// Per-track durations (seconds) from the cached offline session metadata,
+ /// index-aligned with the downloaded track files. Null when unavailable.
+ List<double>? _trackDurations(String itemId) {
+ final raw = DownloadService().getCachedSessionData(itemId);
+ if (raw == null || raw.isEmpty) return null;
+ try {
+ final session = jsonDecode(raw) as Map<String, dynamic>;
+ final tracks = session['audioTracks'] as List<dynamic>?;
+ if (tracks == null || tracks.isEmpty) return null;
+ return tracks
+ .map((t) => ((t as Map<String, dynamic>)['duration'] as num?)?.toDouble() ?? 0.0)
+ .toList();
+ } catch (_) {
+ return null;
+ }
+ }
+
+ /// Ask native code to decode [durationSeconds] of [sourcePath] starting at
+ /// [startSeconds] into a 16kHz mono WAV, returning the temp file path.
+ Future<String?> _extractWav({
+ required String sourcePath,
+ required double startSeconds,
+ required double durationSeconds,
+ }) async {
+ final tmpDir = await getTemporaryDirectory();
+ final outPath =
+ '${tmpDir.path}${Platform.pathSeparator}absorb_transcribe_${DateTime.now().microsecondsSinceEpoch}.wav';
+ try {
+ final ok = await _channel.invokeMethod<bool>('extractWav', {
+ 'sourcePath': sourcePath,
+ 'startSeconds': startSeconds,
+ 'durationSeconds': durationSeconds,
+ 'outPath': outPath,
+ });
+ return ok == true ? outPath : null;
+ } on PlatformException catch (e) {
+ throw TranscriptionException(TranscriptionError.extractFailed, e.message);
+ } on MissingPluginException catch (e) {
+ throw TranscriptionException(TranscriptionError.extractFailed, e.message);
+ }
+ }
+}
diff --git a/lib/widgets/bookmark_detail_dialog.dart b/lib/widgets/bookmark_detail_dialog.dart
index 63692558..095f1e00 100644
--- a/lib/widgets/bookmark_detail_dialog.dart
+++ b/lib/widgets/bookmark_detail_dialog.dart
@@ -1,6 +1,8 @@
+import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
+import 'package:just_audio/just_audio.dart';
import 'package:provider/provider.dart';
import '../l10n/app_localizations.dart';
@@ -10,6 +12,7 @@ import '../services/audio_player_service.dart';
import '../services/bookmark_service.dart';
import '../services/bookmark_preview_player.dart';
import '../services/download_service.dart';
+import '../services/transcription_service.dart';
import 'clip_editor_sheet.dart';
import 'overlay_toast.dart';
@@ -44,6 +47,7 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {
late double _seconds;
late final BookmarkPreviewPlayer _preview;
bool _saving = false;
+ bool _transcriptionOn = false;
// Display-only speed division (speed-adjusted-time setting). _seconds stays
// raw book time throughout - preview, clip export, jump and save all use it.
double _displaySpeed = 1.0;
@@ -61,6 +65,9 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {
..clipLength = const Duration(seconds: 60)
..addListener(_onPreview);
_loadDisplaySpeed();
+ PlayerSettings.getTranscriptionEnabled().then((on) {
+ if (mounted && on) setState(() => _transcriptionOn = true);
+ });
}
Future<void> _loadDisplaySpeed() async {
@@ -190,6 +197,98 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {
);
}
+ String _mapTranscriptionError(AppLocalizations l, TranscriptionError kind) {
+ switch (kind) {
+ case TranscriptionError.disabled:
+ return l.transcriptionDisabledHint;
+ case TranscriptionError.modelMissing:
+ return l.transcriptionNoModelDownloaded;
+ case TranscriptionError.notDownloaded:
+ return l.transcriptionNotDownloadedBook;
+ case TranscriptionError.noMetadata:
+ return l.transcriptionNoMetadataMsg;
+ case TranscriptionError.busy:
+ return l.transcriptionBusyMsg;
+ case TranscriptionError.empty:
+ return l.transcriptionEmptyMsg;
+ case TranscriptionError.extractFailed:
+ case TranscriptionError.transcribeFailed:
+ return l.transcriptionFailedMsg;
+ }
+ }
+
+ /// Transcribe the audio around the (possibly nudged) bookmark time, let the
+ /// user review the text alongside the clip, then append it to the note and
+ /// persist. Downloaded books only - the service guards enforce the rest.
+ Future<void> _transcribe() async {
+ final l = AppLocalizations.of(context)!;
+ await _preview.stop();
+ if (!mounted) return;
+ if (!TranscriptionService.instance.canTranscribeBook(widget.itemId)) {
+ showOverlayToast(context, l.transcriptionNotDownloadedBook,
+ icon: Icons.download_rounded);
+ return;
+ }
+
+ showDialog(
+ context: context,
+ barrierDismissible: false,
+ builder: (_) => AlertDialog(
+ content: Row(children: [
+ const SizedBox(
+ width: 22, height: 22, child: CircularProgressIndicator(strokeWidth: 2.5)),
+ const SizedBox(width: 16),
+ Expanded(child: Text(l.transcribing)),
+ ]),
+ ),
+ );
+
+ ({String text, String audioPath})? result;
+ String? error;
+ try {
+ result = await TranscriptionService.instance
+ .transcribeAt(itemId: widget.itemId, positionSeconds: _seconds);
+ } on TranscriptionException catch (e) {
+ error = _mapTranscriptionError(l, e.kind);
+ } catch (_) {
+ error = l.transcriptionFailedMsg;
+ }
+
+ if (!mounted) return;
+ Navigator.pop(context); // dismiss the progress dialog
+
+ if (error != null) {
+ showOverlayToast(context, error, icon: Icons.error_outline_rounded);
+ return;
+ }
+
+ final edited = await showDialog<String>(
+ context: context,
+ builder: (ctx) => _TranscriptReviewDialog(
+ initialText: result!.text, audioPath: result.audioPath),
+ );
+
+ // The dialog owned the clip while open; clean it up now.
+ try {
+ final f = File(result!.audioPath);
+ if (f.existsSync()) await f.delete();
+ } catch (_) {}
+
+ if (edited == null || !mounted) return; // closed without saving
+ final trimmed = edited.trim();
+ if (trimmed.isEmpty) return;
+ setState(() {
+ _noteC.text =
+ _noteC.text.trim().isEmpty ? trimmed : '${_noteC.text.trim()}\n\n$trimmed';
+ });
+ await _persist();
+ if (mounted) {
+ setState(() => _saving = false);
+ showOverlayToast(context, l.transcriptionSavedToNote,
+ icon: Icons.note_add_rounded);
+ }
+ }
+
Future<void> _persist() async {
setState(() => _saving = true);
await _preview.stop();
@@ -315,6 +414,17 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {
onPressed: _saving ? null : _openClipEditor,
),
),
+ if (_transcriptionOn) ...[
+ const SizedBox(height: 8),
+ SizedBox(
+ width: double.infinity,
+ child: OutlinedButton.icon(
+ icon: const Icon(Icons.record_voice_over_rounded, size: 18),
+ label: Text(l.transcribe),
+ onPressed: _saving ? null : _transcribe,
+ ),
+ ),
+ ],
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.end,
@@ -376,3 +486,137 @@ class _BookmarkDetailSheetState extends State<BookmarkDetailSheet> {
);
}
}
+
+/// Editable transcript plus inline playback of the extracted clip, so the user
+/// can listen to the bookmarked spot while fixing up the text - WITHOUT moving
+/// their real playback position. Uses a separate just_audio player (mirroring
+/// the chapter editor's preview) and pauses the main player while the clip
+/// plays. Returns the edited text on save, or null if closed.
+class _TranscriptReviewDialog extends StatefulWidget {
+ final String initialText;
+ final String audioPath;
+ const _TranscriptReviewDialog({required this.initialText, required this.audioPath});
+
+ @override
+ State<_TranscriptReviewDialog> createState() => _TranscriptReviewDialogState();
+}
+
+class _TranscriptReviewDialogState extends State<_TranscriptReviewDialog> {
+ late final TextEditingController _controller;
+ AudioPlayer? _preview;
+ StreamSubscription<PlayerState>? _stateSub;
+ bool _loading = false;
+ bool _playing = false;
+ bool? _mainWasPlaying;
+
+ @override
+ void initState() {
+ super.initState();
+ _controller = TextEditingController(text: widget.initialText);
+ }
+
+ @override
+ void dispose() {
+ _stateSub?.cancel();
+ _preview?.dispose();
+ _controller.dispose();
+ // Resume the main player if we paused it to audition the clip.
+ if (_mainWasPlaying == true) AudioPlayerService().play();
+ super.dispose();
+ }
+
+ Future<void> _toggle() async {
+ final main = AudioPlayerService();
+
+ // First tap: spin up a separate preview player and load the clip.
+ if (_preview == null) {
+ setState(() => _loading = true);
+ _mainWasPlaying ??= main.isPlaying;
+ if (main.isPlaying) main.pause();
+ final p = AudioPlayer();
+ _preview = p;
+ _stateSub = p.playerStateStream.listen((s) {
+ if (!mounted) return;
+ if (s.processingState == ProcessingState.completed) {
+ p.pause();
+ p.seek(Duration.zero);
+ setState(() => _playing = false);
+ } else {
+ setState(() => _playing = s.playing);
+ }
+ });
+ try {
+ await p.setAudioSource(AudioSource.file(widget.audioPath));
+ } catch (_) {
+ if (mounted) setState(() => _loading = false);
+ return;
+ }
+ if (!mounted) return;
+ setState(() => _loading = false);
+ await p.play();
+ return;
+ }
+
+ final p = _preview!;
+ if (p.playing) {
+ await p.pause();
+ } else {
+ _mainWasPlaying ??= main.isPlaying;
+ if (main.isPlaying) main.pause();
+ if (p.processingState == ProcessingState.completed) {
+ await p.seek(Duration.zero);
+ }
+ await p.play();
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final l = AppLocalizations.of(context)!;
+ return AlertDialog(
+ scrollable: true,
+ icon: const Icon(Icons.record_voice_over_rounded),
+ title: Text(l.transcriptionResultTitle),
+ content: SizedBox(
+ width: double.maxFinite,
+ child: Column(
+ mainAxisSize: MainAxisSize.min,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ TextField(
+ controller: _controller,
+ minLines: 5,
+ maxLines: 12,
+ keyboardType: TextInputType.multiline,
+ textCapitalization: TextCapitalization.sentences,
+ decoration: const InputDecoration(border: OutlineInputBorder()),
+ ),
+ const SizedBox(height: 8),
+ TextButton.icon(
+ icon: _loading
+ ? const SizedBox(
+ width: 18, height: 18,
+ child: CircularProgressIndicator(strokeWidth: 2))
+ : Icon(_playing ? Icons.pause_rounded : Icons.play_arrow_rounded),
+ label: Text(_playing
+ ? l.transcriptionPauseSnippet
+ : l.transcriptionPlaySnippet),
+ onPressed: _loading ? null : _toggle,
+ ),
+ ],
+ ),
+ ),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(context),
+ child: Text(l.bookmarksScreenClose),
+ ),
+ FilledButton.icon(
+ icon: const Icon(Icons.note_add_rounded, size: 18),
+ label: Text(l.transcriptionSaveToNote),
+ onPressed: () => Navigator.pop(context, _controller.text),
+ ),
+ ],
+ );
+ }
+}
diff --git a/lib/widgets/card_buttons.dart b/lib/widgets/card_buttons.dart
index c959828f..357560d9 100644
--- a/lib/widgets/card_buttons.dart
+++ b/lib/widgets/card_buttons.dart
@@ -1039,12 +1039,23 @@ class _SimpleBookmarkSheetState extends State<SimpleBookmarkSheet> {
final titleC = TextEditingController(text: defaultTitle);
final noteC = TextEditingController();
final result = await showDialog<Map<String, String>>(context: context, builder: (ctx) => AlertDialog(
+ scrollable: true,
title: Text(l.addBookmark),
- content: Column(mainAxisSize: MainAxisSize.min, children: [
- TextField(controller: titleC, autofocus: true, decoration: InputDecoration(labelText: l.titleLabel, border: const OutlineInputBorder())),
- const SizedBox(height: 12),
- TextField(controller: noteC, maxLines: 3, decoration: InputDecoration(labelText: l.noteOptionalLabel, border: const OutlineInputBorder(), alignLabelWithHint: true)),
- ]),
+ content: SizedBox(
+ width: double.maxFinite,
+ child: Column(mainAxisSize: MainAxisSize.min, children: [
+ TextField(controller: titleC, autofocus: true, decoration: InputDecoration(labelText: l.titleLabel, border: const OutlineInputBorder())),
+ const SizedBox(height: 12),
+ TextField(
+ controller: noteC,
+ minLines: 3,
+ maxLines: 8,
+ keyboardType: TextInputType.multiline,
+ textCapitalization: TextCapitalization.sentences,
+ decoration: InputDecoration(labelText: l.noteOptionalLabel, border: const OutlineInputBorder(), alignLabelWithHint: true),
+ ),
+ ]),
+ ),
actions: [
TextButton(onPressed: () => Navigator.pop(ctx), child: Text(l.cancel)),
FilledButton(onPressed: () => Navigator.pop(ctx, {'title': titleC.text, 'note': noteC.text}), child: Text(l.save)),
@@ -1062,12 +1073,23 @@ class _SimpleBookmarkSheetState extends State<SimpleBookmarkSheet> {
final titleC = TextEditingController(text: bm.title);
final noteC = TextEditingController(text: bm.note ?? '');
final result = await showDialog<Map<String, String>>(context: context, builder: (ctx) => AlertDialog(
+ scrollable: true,
title: Text(l.editBookmark),
- content: Column(mainAxisSize: MainAxisSize.min, children: [
- TextField(controller: titleC, decoration: InputDecoration(labelText: l.titleLabel, border: const OutlineInputBorder())),
- const SizedBox(height: 12),
- TextField(controller: noteC, maxLines: 3, decoration: InputDecoration(labelText: l.noteOptionalLabel, border: const OutlineInputBorder(), alignLabelWithHint: true)),
- ]),
+ content: SizedBox(
+ width: double.maxFinite,
+ child: Column(mainAxisSize: MainAxisSize.min, children: [
+ TextField(controller: titleC, decoration: InputDecoration(labelText: l.titleLabel, border: const OutlineInputBorder())),
+ const SizedBox(height: 12),
+ TextField(
+ controller: noteC,
+ minLines: 4,
+ maxLines: 10,
+ keyboardType: TextInputType.multiline,
+ textCapitalization: TextCapitalization.sentences,
+ decoration: InputDecoration(labelText: l.noteOptionalLabel, border: const OutlineInputBorder(), alignLabelWithHint: true),
+ ),
+ ]),
+ ),
actions: [
TextButton(onPressed: () => Navigator.pop(ctx), child: Text(l.cancel)),
FilledButton(onPressed: () => Navigator.pop(ctx, {'title': titleC.text, 'note': noteC.text}), child: Text(l.save)),
diff --git a/pubspec.lock b/pubspec.lock
index dd2eaf7e..f9f5dedd 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -1,6 +1,22 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
+ _fe_analyzer_shared:
+ dependency: transitive
+ description:
+ name: _fe_analyzer_shared
+ sha256: "1b0e6a07425a3e460666e88bf1c949ccc7bb0116ad562ce94a1eca60fe820725"
+ url: "https://pub.dev"
+ source: hosted
+ version: "103.0.0"
+ analyzer:
+ dependency: transitive
+ description:
+ name: analyzer
+ sha256: "61c04d0c1bfed555c681ea079519933f071a5a026578ff73c4ff0df2d3462e5e"
+ url: "https://pub.dev"
+ source: hosted
+ version: "13.3.0"
ansicolor:
dependency: transitive
description:
@@ -160,6 +176,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.4"
+ cli_config:
+ dependency: transitive
+ description:
+ name: cli_config
+ sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
cli_util:
dependency: transitive
description:
@@ -208,6 +232,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.1"
+ convert:
+ dependency: transitive
+ description:
+ name: convert
+ sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.1.2"
+ coverage:
+ dependency: transitive
+ description:
+ name: coverage
+ sha256: "956a3de0725ca232ad353565a8290d3357592bf4250f6f298a185e2d949c5d3d"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.15.1"
cross_file:
dependency: transitive
description:
@@ -481,6 +521,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.31"
+ flutter_riverpod:
+ dependency: transitive
+ description:
+ name: flutter_riverpod
+ sha256: "56e81e662e6e54e59b231da57e90ac0d06ac67d8e3f2273c129a37ae6282b40c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.4.2"
flutter_test:
dependency: "direct dev"
description: flutter
@@ -507,6 +555,22 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
+ freezed_annotation:
+ dependency: transitive
+ description:
+ name: freezed_annotation
+ sha256: "7294967ff0a6d98638e7acb774aac3af2550777accd8149c90af5b014e6d44d8"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.1.0"
+ frontend_server_client:
+ dependency: transitive
+ description:
+ name: frontend_server_client
+ sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.0.0"
get:
dependency: transitive
description:
@@ -515,6 +579,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.7.3"
+ glob:
+ dependency: transitive
+ description:
+ name: glob
+ sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.3"
gtk:
dependency: transitive
description:
@@ -555,6 +627,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.6.0"
+ http_multi_server:
+ dependency: transitive
+ description:
+ name: http_multi_server
+ sha256: aa6199f908078bb1c5efb8d8638d4ae191aac11b311132c3ef48ce352fb52ef8
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.2.2"
http_parser:
dependency: transitive
description:
@@ -595,6 +675,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.20.3"
+ io:
+ dependency: transitive
+ description:
+ name: io
+ sha256: dfd5a80599cf0165756e3181807ed3e77daf6dd4137caaad72d0b7931597650b
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.5"
js:
dependency: transitive
description:
@@ -607,10 +695,10 @@ packages:
dependency: transitive
description:
name: json_annotation
- sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
+ sha256: "2a743920d81b7910627f68ee2c9ac1fc0bfee32b9fc3403587d7c6791ca12f80"
url: "https://pub.dev"
source: hosted
- version: "4.9.0"
+ version: "4.12.0"
just_audio:
dependency: "direct main"
description:
@@ -666,6 +754,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.0"
+ listen:
+ dependency: transitive
+ description:
+ name: listen
+ sha256: "47501a08016a43fcad79252439d723f50f14f88fa7bfd8a177e0a417e5c9e1f2"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.1"
logging:
dependency: transitive
description:
@@ -746,6 +842,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.0"
+ node_preamble:
+ dependency: transitive
+ description:
+ name: node_preamble
+ sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.2"
octo_image:
dependency: transitive
description:
@@ -762,6 +866,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.7.0"
+ package_config:
+ dependency: transitive
+ description:
+ name: package_config
+ sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.2.0"
package_info_plus:
dependency: "direct main"
description:
@@ -946,6 +1058,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
+ pool:
+ dependency: transitive
+ description:
+ name: pool
+ sha256: "978783255c543aa3586a1b3c21f6e9d720eb315376a915872c61ef8b5c20177d"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.5.2"
posix:
dependency: transitive
description:
@@ -1034,6 +1154,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.6.5"
+ riverpod:
+ dependency: transitive
+ description:
+ name: riverpod
+ sha256: "84351b3472a447f7b89f961f95c73287009d58c59d8cc1267425d995f78e50f1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.4.2"
rxdart:
dependency: transitive
description:
@@ -1130,6 +1258,38 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.4.1"
+ shelf:
+ dependency: transitive
+ description:
+ name: shelf
+ sha256: e7dd780a7ffb623c57850b33f43309312fc863fb6aa3d276a754bb299839ef12
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.2"
+ shelf_packages_handler:
+ dependency: transitive
+ description:
+ name: shelf_packages_handler
+ sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.2"
+ shelf_static:
+ dependency: transitive
+ description:
+ name: shelf_static
+ sha256: c87c3875f91262785dade62d135760c2c69cb217ac759485334c5857ad89f6e3
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.3"
+ shelf_web_socket:
+ dependency: transitive
+ description:
+ name: shelf_web_socket
+ sha256: "3632775c8e90d6c9712f883e633716432a27758216dfb61bd86a8321c0580925"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.0"
sky_engine:
dependency: transitive
description: flutter
@@ -1151,6 +1311,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.1.1"
+ source_map_stack_trace:
+ dependency: transitive
+ description:
+ name: source_map_stack_trace
+ sha256: c0713a43e323c3302c2abe2a1cc89aa057a387101ebd280371d6a6c9fa68516b
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.2"
+ source_maps:
+ dependency: transitive
+ description:
+ name: source_maps
+ sha256: "190222579a448b03896e0ca6eca5998fa810fda630c1d65e2f78b3f638f54812"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.10.13"
source_span:
dependency: transitive
description:
@@ -1207,6 +1383,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.12.1"
+ state_notifier:
+ dependency: transitive
+ description:
+ name: state_notifier
+ sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.0"
stream_channel:
dependency: transitive
description:
@@ -1239,6 +1423,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.2"
+ test:
+ dependency: transitive
+ description:
+ name: test
+ sha256: ca578dc12bb8b2f40b67b7d3bd2fac4f31c01a6ff7130a14e2597b919934507f
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.31.1"
test_api:
dependency: transitive
description:
@@ -1247,6 +1439,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.7.12"
+ test_core:
+ dependency: transitive
+ description:
+ name: test_core
+ sha256: d2e98ec12998368dc59ddd47ab709f2cd55acd6b66dc7db764455a44082f4bc5
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.6.18"
timezone:
dependency: transitive
description:
@@ -1375,6 +1575,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "15.0.0"
+ watcher:
+ dependency: transitive
+ description:
+ name: watcher
+ sha256: "1398c9f081a753f9226febe8900fce8f7d0a67163334e1c94a2438339d79d635"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.2.1"
web:
dependency: "direct main"
description:
@@ -1383,6 +1591,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.1"
+ web_socket:
+ dependency: transitive
+ description:
+ name: web_socket
+ sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.1"
+ web_socket_channel:
+ dependency: transitive
+ description:
+ name: web_socket_channel
+ sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.3"
+ webkit_inspection_protocol:
+ dependency: transitive
+ description:
+ name: webkit_inspection_protocol
+ sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.2.1"
webview_flutter:
dependency: "direct main"
description:
@@ -1415,6 +1647,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.23.0"
+ whisper_ggml_plus:
+ dependency: "direct main"
+ description:
+ name: whisper_ggml_plus
+ sha256: "484950d7767078bd3256fbb256d663322e33de359537a3f3ae0c82607ebebc5c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.5.2"
win32:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index d49bae2a..9590f6ac 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -33,6 +33,10 @@ dependencies:
audio_service:
path: packages/audio_service
+ # On-device bookmark transcription (Whisper, opt-in). No ffmpeg companion:
+ # we feed it 16kHz mono WAV produced by native decoders (MediaCodec / AVAssetReader).
+ whisper_ggml_plus: ^1.5.2
+
# CarPlay - vendored copy of 1.2.11 with a patched image loader (downsampled +
# cached list thumbnails) so large browse lists don't run CarPlay out of memory.
flutter_carplay: