plapre-pico-coreml / swift-cli /Sources /Configuration.swift
Daniel Rothmann
Remove int4 variant which had too poor quality
5ed6654
import Foundation
/// Configuration constants for the Plapre Pico TTS pipeline.
/// These values are fixed by the model architecture and must match the converted CoreML models.
enum PlapreConfig {
// MARK: - Audio Parameters
static let sampleRate = 24_000
static let audioTokensPerSecond = 25
// MARK: - Model Architecture
static let vocabSize = 20_802
static let maxContextLength = 512
static let prefillSequenceLength = 512
static let hiddenDimension = 576
static let headDimension = 64
static let numKVHeads = 3
static let speakerEmbeddingDimension = 128
// MARK: - Token Ranges
static let eosToken: Int32 = 0
static let textMarkerToken: Int32 = 8_000
static let audioMarkerToken: Int32 = 8_001
static let audioTokenOffset = 8_002
static let audioTokenMax = 20_801
// MARK: - Inference Parameters
static let defaultTemperature: Float = 0.8
static let defaultTopK = 50
static let maxGenerationTokens = 500
static let nonAudioStopThreshold = 10
// MARK: - Vocoder Parameters
static let kanadeChunkSize = 100 // 4 seconds at 25 tok/s
// MARK: - Paths
/// Computes the repository root directory from the current source file location.
/// Traverses: Sources → swift-cli → repo root
static var repoRoot: URL {
URL(fileURLWithPath: #filePath)
.deletingLastPathComponent() // Sources
.deletingLastPathComponent() // swift-cli
.deletingLastPathComponent() // repo root
}
/// Returns the URL for a model package, accounting for quantization flags.
static func modelURL(for name: String, useInt8: Bool) -> URL {
if name == "PlaprePico" && useInt8 {
return repoRoot.appendingPathComponent("PlaprePico_int8.mlpackage")
}
return repoRoot.appendingPathComponent("\(name).mlpackage")
}
}