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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Sources/FluidAudio/TTS/KokoroAne/KokoroAneManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,18 @@ public actor KokoroAneManager {
/// and vocab-supported punctuation kept as prosody/pause tokens.
private func phonemize(text: String) async throws -> String {
let phonemizer = await ensureEnglishPhonemizer()
return try await phonemizer.phonemize(text) { word in
let raw = try await phonemizer.phonemize(text) { word in
try await G2PModel.shared.phonemize(word: word)
}
return Self.misakiOutputForm(raw)
}

/// misaki's flap step for Kokoro v1.0 (`G2P.__call__`): `ɾ` → `T`. The
/// lexicon stores the raw flap ("metal" was read as "mattle"). misaki also
/// maps the glottal stop `ʔ` → `t`, but this chain reads `ʔn` better than
/// `tn` ("button" became "butt"), so `ʔ` is kept.
static func misakiOutputForm(_ phonemes: String) -> String {
phonemes.replacingOccurrences(of: "ɾ", with: "T")
}

/// Build (and cache) the English frontend: chain vocab → allowed
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import XCTest

@testable import FluidAudio

/// misaki's `ɾ` → `T` flap step on the English frontend output.
final class KokoroAneMisakiOutputFormTests: XCTestCase {

func testFlapBecomesT() {
XCTAssertEqual(KokoroAneManager.misakiOutputForm("mˈɛɾᵊl wˈɔɾəɹ"), "mˈɛTᵊl wˈɔTəɹ")
}

func testGlottalStopIsKept() {
XCTAssertEqual(KokoroAneManager.misakiOutputForm("bˈʌʔn"), "bˈʌʔn")
}
}
Loading