From e9ca938a28274e25e273b3ea92043e81bb789e6a Mon Sep 17 00:00:00 2001 From: gullabi Date: Thu, 14 Dec 2023 12:45:59 +0100 Subject: [PATCH] segmentation problem fixed --- server/server.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/server.py b/server/server.py index e3e1464..1d91079 100644 --- a/server/server.py +++ b/server/server.py @@ -18,6 +18,7 @@ from itertools import chain from pathlib import Path from typing import Union +from pysbd import Segmenter # PyTorch for deep learning operations import torch @@ -55,6 +56,9 @@ model_ca = os.path.join(path_dir, models_path_rel, 'best_model.pth') config_ca = os.path.join(path_dir, models_path_rel, 'config.json') +# Initialize sentence segmenter +segmenter = Segmenter(language="en") + def create_argparser(): def convert_boolean(x): return x.lower() in ["true", "1", "yes"] @@ -357,14 +361,14 @@ async def tts(request: TTSRequestModel): model = app.state.synthesizer - sentences = text.split('.') + sentences = segmenter.segment(text) mp_workers = args.mp_workers worker_with_args = partial(worker, speaker_id=speaker_id, model=model, use_aliases=speaker_config_attributes["use_aliases"], new_speaker_ids=speaker_config_attributes["new_speaker_ids"]) pool = mp.Pool(processes=mp_workers) - results = pool.map(worker_with_args, [sentence.strip() + '.' for sentence in sentences if sentence]) + results = pool.map(worker_with_args, [sentence.strip() for sentence in sentences if sentence]) # Close the pool to indicate that no more tasks will be submitted pool.close()