# Add int8 dynamic quantization
Closes#7
## Summary
This PR implements mixed-precision int8 dynamic quantization for
pocket-tts, as requested in issue #7. It adds a `quantize=True` flag to
`TTSModel.load_model()` that reduces runtime memory usage by ~48% and
improves inference speed by ~27% on x86 and up to 23% on ARM, with no
measurable impact on audio quality.
-modify main,py to not hardcode using DEFAULT_VARIANT
-allow submission of path string to path of variant.yaml file saved in
custom directory in lieu of model variant identifier in CLI to use when
loading model
-addresses #57
Quality of life improvement to save user voice embedding as a
.safetensors file that can be loaded for subsequent use, achieving the
same efficiency as the predefined voices, all via the existing
get_state_for_audio_prompt function.
---------
Co-authored-by: Václav Volhejn <8401624+vvolhejn@users.noreply.github.com>
This pull request addresses issue #38
**Changes included:**
- Added a `max_tokens` parameter to the typer cli for the `generate`
command, allowing user to set a default number of tokens per chunk.
- Introduced a default variable `MAX_TOKEN_PER_CHUNK` to centralize the
default value.
- Fixed a tokenization issue by inserting a comma, allowing the model to
correctly read each chunk as intended rather than treating one chunk as
a single sentence.
**Future improvement suggestion :**
- Consider enhancing the `split_into_best_sentences` function using
regex to split text more accurately without modifying it, which would
improve clarity and maintainability.
---------
Co-authored-by: Václav Volhejn <8401624+vvolhejn@users.noreply.github.com>
The `frames_after_eos` parameter in `generate_audio_stream()` and
`generate_audio()` was accepted but never used - the code always used
the auto-calculated guess.
**Before:** User passes `frames_after_eos=0` → ignored, uses guess (3+
frames of silence)
**After:** User passes `frames_after_eos=0` → respected, minimal
trailing silence
Default behavior preserved when `frames_after_eos=None`.
I *think* this is the intention of that argument.
`torch.no_grad` is thread local, I now run the autoregressive generation
in a separate thread, in addition of the thread running mimi, and forgot
to add `torch.no_grad` to the function inside this thread.