-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add tts pipeline - add tn pipeline - refactor ssml gen - add 增加 stream_chunk_size 参数 - add 简单的多线程 - add tn_config - refactor batch generate - add 增加 wetext tn (处理 en) - TODO 适配 api - TODO 适配 webui - TODO 支持其他model
- Loading branch information
Showing
85 changed files
with
1,891 additions
and
462 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from typing import Generator | ||
|
||
import numpy as np | ||
from fastapi import HTTPException | ||
|
||
from modules.core.handler.AudioHandler import AudioHandler | ||
from modules.core.handler.datacls.audio_model import AdjustConfig | ||
from modules.core.handler.datacls.chattts_model import ChatTTSConfig, InferConfig | ||
from modules.core.handler.datacls.enhancer_model import EnhancerConfig | ||
from modules.core.pipeline.factory import PipelineFactory | ||
from modules.core.pipeline.pipeline import TTSPipeline | ||
from modules.core.pipeline.processor import TTSPipelineContext | ||
from modules.core.ssml.SSMLParser import create_ssml_v01_parser | ||
from modules.core.ssml.SynthesizeSSML import SynthesizeSSML | ||
from modules.Enhancer.ResembleEnhance import apply_audio_enhance_full | ||
from modules.normalization import text_normalize | ||
from modules.utils import audio_utils | ||
|
||
|
||
class SSMLHandler(AudioHandler): | ||
def __init__( | ||
self, | ||
ssml_content: str, | ||
infer_config: InferConfig, | ||
adjust_config: AdjustConfig, | ||
enhancer_config: EnhancerConfig, | ||
) -> None: | ||
assert isinstance(ssml_content, str), "ssml_content must be a string." | ||
assert isinstance( | ||
infer_config, InferConfig | ||
), "infer_config must be an InferConfig object." | ||
assert isinstance( | ||
adjust_config, AdjustConfig | ||
), "adjest_config should be AdjustConfig" | ||
assert isinstance( | ||
enhancer_config, EnhancerConfig | ||
), "enhancer_config must be an EnhancerConfig object." | ||
|
||
self.ssml_content = ssml_content | ||
self.infer_config = infer_config | ||
self.adjest_config = adjust_config | ||
self.enhancer_config = enhancer_config | ||
|
||
self.validate() | ||
|
||
def validate(self): | ||
# TODO params checker | ||
pass | ||
|
||
def create_pipeline(self): | ||
ssml_content = self.ssml_content | ||
infer_config = self.infer_config | ||
adjust_config = self.adjest_config | ||
enhancer_config = self.enhancer_config | ||
|
||
ctx = TTSPipelineContext( | ||
ssml=ssml_content, | ||
tts_config=ChatTTSConfig(), | ||
infer_config=infer_config, | ||
adjust_config=adjust_config, | ||
enhancer_config=enhancer_config, | ||
) | ||
pipeline = PipelineFactory.create(ctx) | ||
return pipeline | ||
|
||
def enqueue(self) -> tuple[np.ndarray, int]: | ||
pipeline = self.create_pipeline() | ||
results = pipeline.generate() | ||
|
||
sample_rate = results[0][0] | ||
audio_data = np.concatenate([r[1] for r in results], axis=0) | ||
|
||
return audio_data, sample_rate | ||
|
||
def enqueue_stream(self) -> Generator[tuple[np.ndarray, int], None, None]: | ||
pipeline = self.create_pipeline() | ||
# TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
class TNConfig(BaseModel): | ||
enabled: Optional[list[str]] = None | ||
disabled: Optional[list[str]] = None |
Empty file.
Oops, something went wrong.