Skip to content

Commit

Permalink
segmentation problem fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
gullabi committed Dec 14, 2023
1 parent a33bc4f commit e9ca938
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e9ca938

Please sign in to comment.