A TTS that fits in your CPU (and pocket)
Python
Immutable defaults in seanet; document the two open() call sites (#260)
manu-lma61b7878bb71
diff --git a/pocket_tts/data/audio.py b/pocket_tts/data/audio.pyindex a5358b4..734acba 100644--- a/pocket_tts/data/audio.py+++ b/pocket_tts/data/audio.py@@ -73,7 +73,8 @@ class StreamingWAVWriter:"""Initialize WAV writer with header."""# For stdout streaming, we need to handle the unseekable stream case# The wave module supports unseekable streams since Python 3.4- self.wave_writer = wave.open(self.output_stream, "wb")+ # Closed with the underlying stream by the caller's `with f:` block.+ self.wave_writer = wave.open(self.output_stream, "wb") # noqa: SIM115self.wave_writer.setnchannels(1) # Monoself.wave_writer.setsampwidth(2) # 16-bitself.wave_writer.setframerate(sample_rate)@@ -148,7 +149,7 @@ def stream_audio_chunks(elif is_file_like(path):f = pathelse:- f = open(path, "wb")+ f = open(path, "wb") # noqa: SIM115 -- closed by the `with f:` belowwith f:if path is not None:diff --git a/pocket_tts/modules/seanet.py b/pocket_tts/modules/seanet.pyindex 0971852..9ceff05 100644--- a/pocket_tts/modules/seanet.py+++ b/pocket_tts/modules/seanet.py@@ -1,3 +1,5 @@+from collections.abc import Sequence+import numpy as npimport torch.nn as nn@@ -8,8 +10,8 @@ class SEANetResnetBlock(nn.Module):def __init__(self,dim: int,- kernel_sizes: list[int] = [3, 1],- dilations: list[int] = [1, 1],+ kernel_sizes: Sequence[int] = (3, 1),+ dilations: Sequence[int] = (1, 1),pad_mode: str = "reflect",compress: int = 2,):@@ -48,7 +50,7 @@ class SEANetEncoder(nn.Module):dimension: int = 128,n_filters: int = 32,n_residual_layers: int = 3,- ratios: list[int] = [8, 5, 4, 2],+ ratios: Sequence[int] = (8, 5, 4, 2),kernel_size: int = 7,last_kernel_size: int = 7,residual_kernel_size: int = 3,@@ -120,7 +122,7 @@ class SEANetDecoder(nn.Module):dimension: int = 128,n_filters: int = 32,n_residual_layers: int = 3,- ratios: list[int] = [8, 5, 4, 2],+ ratios: Sequence[int] = (8, 5, 4, 2),kernel_size: int = 7,last_kernel_size: int = 7,residual_kernel_size: int = 3,@@ -132,7 +134,7 @@ class SEANetDecoder(nn.Module):self.dimension = dimensionself.channels = channelsself.n_filters = n_filters- self.ratios = ratios+ self.ratios = list(ratios)del ratiosself.n_residual_layers = n_residual_layersself.hop_length = int(np.prod(self.ratios))