-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 简单支持 stream - 缺少 enhance - 缺少 adjust - 缺少 lru_cache - 缺少 batch generate
- Loading branch information
Showing
6 changed files
with
199 additions
and
14 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import io | ||
from typing import Generator, Union | ||
|
||
import numpy as np | ||
|
||
from modules import generate_audio as generate | ||
from modules.SentenceSplitter import SentenceSplitter | ||
from modules.speaker import Speaker | ||
|
||
|
||
def synthesize_stream( | ||
text: str, | ||
temperature: float = 0.3, | ||
top_P: float = 0.7, | ||
top_K: float = 20, | ||
spk: Union[int, Speaker] = -1, | ||
infer_seed: int = -1, | ||
use_decoder: bool = True, | ||
prompt1: str = "", | ||
prompt2: str = "", | ||
prefix: str = "", | ||
spliter_threshold: int = 100, | ||
end_of_sentence="", | ||
) -> Generator[tuple[int, np.ndarray], None, None]: | ||
spliter = SentenceSplitter(spliter_threshold) | ||
sentences = spliter.parse(text) | ||
|
||
for sentence in sentences: | ||
wav_gen = generate.generate_audio_stream( | ||
text=sentence + end_of_sentence, | ||
temperature=temperature, | ||
top_P=top_P, | ||
top_K=top_K, | ||
spk=spk, | ||
infer_seed=infer_seed, | ||
use_decoder=use_decoder, | ||
prompt1=prompt1, | ||
prompt2=prompt2, | ||
prefix=prefix, | ||
) | ||
for sr, wav in wav_gen: | ||
yield sr, wav |