VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.
Python aiaudiobookcudadubbingelevenlabs-alternativehuggingfacelocal-firstmlxomnivoice-studiospeech-to-texttext-to-speechtranscriptiontranslatettsvoice-aivoice-cloningvoice-generationvoicestudioworkflow
fix(mobile): reserve disk across concurrent Android model downloads and guard iOS runtime-absence assertions
debpalash703d970a7e7d
diff --git a/mobile/android/core/local/src/main/kotlin/com/voicestudio/mobile/local/ModelDownloads.kt b/mobile/android/core/local/src/main/kotlin/com/voicestudio/mobile/local/ModelDownloads.ktindex 34983dd5d..716d46fe9 100644--- a/mobile/android/core/local/src/main/kotlin/com/voicestudio/mobile/local/ModelDownloads.kt+++ b/mobile/android/core/local/src/main/kotlin/com/voicestudio/mobile/local/ModelDownloads.kt@@ -44,6 +44,7 @@ class ModelDownloads internal constructor(}private fun invalidate(model: PhoneModel) {model.files.forEach {verified.remove(File(dir(model),it.path))}}private val locks=ConcurrentHashMap<String,Mutex>()+ private val reservations=HashMap<String,Long>()private fun lock(model: PhoneModel)=locks.getOrPut(model.id) {Mutex()}private val mutable=MutableStateFlow<Map<String,DownloadProgress>>(emptyMap())val progress=mutable.asStateFlow()@@ -68,7 +69,11 @@ class ModelDownloads internal constructor(val partial=File(directory,f.path+".part").length().takeIf {it<=f.size} ?: 0Lf.size-partial}- if(freeBytes()<needed+16*1024*1024) throw ClientFailure("mobile.local.storage_required")+ // Concurrent downloads each pass the check alone; reserve what the others still need.+ synchronized(reservations) {+ if(freeBytes()-reservations.values.sum()<needed+16*1024*1024) throw ClientFailure("mobile.local.storage_required")+ reservations[model.id]=needed+ }mutable.update {it+(model.id to DownloadProgress(total=model.totalBytes,running=true))}try {var completed=0L@@ -102,7 +107,7 @@ class ModelDownloads internal constructor(catch(e:Exception) {val failure=e as? ClientFailure ?: ClientFailure("mobile.local.download_failed")mutable.update {it+(model.id to DownloadProgress(total=model.totalBytes,error=failure.key))};throw failure- }+ } finally {synchronized(reservations) {reservations.remove(model.id)}}}}private fun allowed(url: HttpUrl): Boolean = allowTestHttp || (url.scheme=="https" && url.username.isEmpty() && url.password.isEmpty() &&diff --git a/mobile/ios/VoiceStudioKit/Tests/VoiceStudioKitTests/LocalInferenceTests.swift b/mobile/ios/VoiceStudioKit/Tests/VoiceStudioKitTests/LocalInferenceTests.swiftindex 9f2ecd941..2c4033797 100644--- a/mobile/ios/VoiceStudioKit/Tests/VoiceStudioKitTests/LocalInferenceTests.swift+++ b/mobile/ios/VoiceStudioKit/Tests/VoiceStudioKitTests/LocalInferenceTests.swift@@ -181,8 +181,11 @@ private actor RangeServer: HTTPTransport {let root = try localDirectory(); defer { try? FileManager.default.removeItem(at: root) }let store = try ModelStore(root: root, available: { _ in 100_000_000_000 }), engine = NativeLocalEngine(store: store)let clone = try localFixture(capability: "clone"), translate = try localFixture(capability: "translate")+ #if !os(iOS)+ // iOS links the runtimes statically, so a missing library path cannot make them unavailable there.#expect(!NativeLocalEngine.runtimeAvailable(.omni, library: "/does-not-exist"))#expect(!NativeLocalEngine.runtimeAvailable(.llama, library: "/does-not-exist"))+ #endifawait #expect(throws: (any Error).self) { try await engine.clone(model: clone, text: "Hello", reference: PCMChunk(samples: [0], sampleRate: 16000), referenceText: "Reference") }try await store.download(translate, wifi: { true }, transport: RangeServer(bytes: Data("model".utf8)))await #expect(throws: (any Error).self) { try await engine.translate(model: translate, text: "Hello", sourceLanguage: "en", targetLanguage: "fr") }