Text-to-Speech
Core ML
tts
kokoro
File size: 765 Bytes
5522488
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
--- ref/kokoro/custom_stft.py
+++ ref/kokoro/custom_stft.py
@@ -255,9 +255,10 @@
         # PyTorch and ONNX handle atan2(0, negative) differently
         # PyTorch returns π, ONNX returns -π
         # Manual correction ensures consistent behavior across platforms
-        correction_mask = (imag_out == 0) & (real_out < 0)
-        phase[correction_mask] = torch.pi
-        return magnitude, phase
+        # CoreML-friendly: float-mask blend instead of bitwise-and + boolean scatter.
+        correction = (imag_out == 0).to(phase.dtype) * (real_out < 0).to(phase.dtype)
+        phase = phase * (1.0 - correction) + torch.pi * correction
+        return magnitude, phase


     def inverse(self, magnitude: torch.Tensor, phase: torch.Tensor, length=None):