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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ let package = Package(
dependencies: [
"FastClusterWrapper",
"MachTaskSelfWrapper",
"NemoTextProcessing",
.target(name: "NemoTextProcessing", condition: .when(platforms: [.macOS, .iOS])),
],
path: "Sources/FluidAudio",
exclude: ["ASR/Parakeet/Unified/benchmark.md"],
Expand Down
3 changes: 3 additions & 0 deletions Sources/FluidAudio/ITN/TextNormalizer.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(CNemoTextProcessing)
import CNemoTextProcessing
import Foundation
import NaturalLanguage
Expand Down Expand Up @@ -254,3 +255,5 @@ public final class TextNormalizer: Sendable {
return out
}
}

#endif
4 changes: 4 additions & 0 deletions Sources/FluidAudio/TTS/KokoroAne/KokoroAneManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,11 @@ public actor KokoroAneManager {
// Normalize written forms to their Mandarin reading before
// segmentation — e.g. "$5" → "五美元", "2024年" → "二零二四年" —
// so the numeric/semiotic tokens reach MandarinG2P as Hanzi.
#if canImport(CNemoTextProcessing)
let normalized = NemoTextNormalizer.normalize(text, language: .mandarin)
#else
let normalized = text
#endif
if MandarinG2P.looksLikeHanzi(normalized) {
let g2p = try await store.mandarinG2PPipeline()
return try await g2p.phonemize(normalized)
Expand Down
4 changes: 4 additions & 0 deletions Sources/FluidAudio/TTS/Shared/EnglishTextNormalizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,12 @@ enum EnglishTextNormalizer {
/// engine leaves the text unchanged (e.g. plain prose, or a build without
/// the `fst-engine` feature).
static func normalizeForFrontend(_ text: String) -> String {
#if canImport(CNemoTextProcessing)
let fst = NemoTextNormalizer.normalize(text, language: .english)
return fst == text ? normalize(text) : fst
#else
return normalize(text)
#endif
}

// MARK: - Boundaries
Expand Down
3 changes: 3 additions & 0 deletions Sources/FluidAudio/TTS/Shared/NemoTextNormalizer.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if canImport(CNemoTextProcessing)
import CNemoTextProcessing
import Foundation

Expand Down Expand Up @@ -34,3 +35,5 @@ public enum NemoTextNormalizer {
return String(cString: ptr)
}
}

#endif
Loading