A TTS that fits in your CPU (and pocket)
Python
Fix temp file issue on windows (I hope) (#72)
Václav Volhejn2d62797f282a
diff --git a/pocket_tts/main.py b/pocket_tts/main.pyindex 0fbc057..c9711a1 100644--- a/pocket_tts/main.py+++ b/pocket_tts/main.py@@ -39,7 +39,7 @@ cli_app = typer.Typer(# ------------------------------------------------------# Global model instance-tts_model = None+tts_model: TTSModel | None = Noneglobal_model_state = Noneweb_app = FastAPI(@@ -151,13 +151,13 @@ def text_to_speech(content = voice_wav.file.read()temp_file.write(content)temp_file.flush()+ temp_file_path = temp_file.name- try:- model_state = tts_model.get_state_for_audio_prompt(- Path(temp_file.name), truncate=True- )- finally:- os.unlink(temp_file.name)+ # Close the file before reading it back (required on Windows)+ try:+ model_state = tts_model.get_state_for_audio_prompt(Path(temp_file_path), truncate=True)+ finally:+ os.unlink(temp_file_path)else:# Use default global model statemodel_state = global_model_state