Spaces:
Runtime error
Runtime error
zhzluke96 commited on
Commit ·
ebc4336
1
Parent(s): 21473c0
update
Browse filesFiles changed (19)
- language/zh-CN.json+3-2
- modules/api/impl/google_api.py+12-6
- modules/api/impl/openai_api.py+5-1
- modules/api/impl/refiner_api.py+5-1
- modules/api/impl/ssml_api.py+15-5
- modules/api/impl/tts_api.py+38-1
- modules/generate_audio.py+5-1
- modules/normalization.py+6
- modules/ssml.py-242
- modules/ssml_parser/SSMLParser.py+9-3
- modules/utils/git.py+15
- modules/utils/markdown.py+7
- modules/webui/localization.py+9-3
- modules/webui/speaker/speaker_editor.pyAdded+147
- modules/webui/speaker_tab.py+3
- modules/webui/ssml/podcast_tab.py+38-17
- modules/webui/tts_tab.py+3-1
- modules/webui/webui_utils.py+1-3
- webui.py+1-4
56 unmodified lines5758596061606162636414 unmodified lines7980818283848556 unmodified lines "🔊Generate speaker.pt": "🔊生成 speaker.pt", "Save .pt file": "保存.pt文件", "Save to File": "保存到文件", "🎤Test voice": "🎤测试语音", "Test Voice": "测试语音", "🎤Test voice": "🎤试语", "Test Voice": "试语", "Current Seed": "当前种子", "Output Audio": "输出音频", "Merger": "融合",14 unmodified lines "README": "README", "readme": "readme", "changelog": "changelog", "💼Speaker file": "💼音色文件", "TTS_STYLE_GUIDE": ["后缀为 _p 表示带prompt,效果更强但是影响质量"], "SSML_SPLITER_GUIDE": [ "- 字数限制详见README,超过部分将截断",13 unmodified lines141516171718192044 unmodified lines656667686970717215 unmodified lines888990899091919293949525 unmodified lines12112212312412312512612712844 unmodified lines17317417517617717817917418018118218313 unmodified linesfrom modules.speaker import speaker_mgr
from modules.ssml import parse_ssmlfrom modules.ssml_parser.SSMLParser import create_ssml_parserfrom modules.SynthesizeSegments import ( SynthesizeSegments, combine_audio_segments,44 unmodified lines audioConfig = request.audioConfig
# 提取参数
# TODO 这个也许应该传给 normalizer language_code = voice.languageCode voice_name = voice.name infer_seed = voice.seed or 4215 unmodified lines # TODO maybe need to change the sample rate sample_rate = 24000
# TODO 使用 speaker spk = speaker_mgr.get_speaker(voice_name) if spk is None: # 虽然 calc_spk_style 可以解析 seed 形式,但是这个接口只准备支持 speakers list 中存在的 speaker if speaker_mgr.get_speaker(voice_name) is None: raise HTTPException( status_code=400, detail="The specified voice name is not supported." )25 unmodified lines
elif input.ssml: # 处理SSML合成逻辑 parser = create_ssml_parser() segments = parse_ssml(input.ssml) segments = parser.parse(input.ssml) for seg in segments: seg["text"] = text_normalize(seg["text"], is_end=True)
44 unmodified lines import logging
logging.exception(e)
if isinstance(e, HTTPException): raise e else: raise HTTPException(status_code=500, detail=str(e)) raise HTTPException(status_code=500, detail=str(e))
def setup(app: APIManager):114 unmodified lines115116117118119120121118122123124125114 unmodified lines import logging
logging.exception(e)
if isinstance(e, HTTPException): raise e else: raise HTTPException(status_code=500, detail=str(e)) raise HTTPException(status_code=500, detail=str(e))
class TranscribeSegment(BaseModel):41 unmodified lines42434445464748454950515241 unmodified lines import logging
logging.exception(e)
if isinstance(e, HTTPException): raise e else: raise HTTPException(status_code=500, detail=str(e)) raise HTTPException(status_code=500, detail=str(e))
def setup(api_manager: APIManager):6 unmodified lines789101011121320 unmodified lines34353637373839401 unmodified line42434445454647484950515253485455565711 unmodified lines6970717273747566767778796 unmodified lines
from modules.normalization import text_normalizefrom modules.ssml import parse_ssmlfrom modules.ssml_parser.SSMLParser import create_ssml_parserfrom modules.SynthesizeSegments import ( SynthesizeSegments, combine_audio_segments,20 unmodified lines): try: ssml = request.ssml format = request.format format = request.format.lower() batch_size = request.batch_size
if batch_size < 1:1 unmodified line status_code=400, detail="Batch size must be greater than 0." )
if not ssml: if not ssml or ssml == "": raise HTTPException(status_code=400, detail="SSML content is required.")
if format not in ["mp3", "wav"]: raise HTTPException( status_code=400, detail="Format must be 'mp3' or 'wav'." )
parser = create_ssml_parser() segments = parse_ssml(ssml) segments = parser.parse(ssml) for seg in segments: seg["text"] = text_normalize(seg["text"], is_end=True)
11 unmodified lines import logging
logging.exception(e)
if isinstance(e, HTTPException): raise e else: raise HTTPException(status_code=500, detail=str(e)) raise HTTPException(status_code=500, detail=str(e))
def setup(api_manager: APIManager):43 unmodified lines44454647484950515253545556575859606162636465666768697071727374757677787980818237 unmodified lines1201211221231241251269012712812913043 unmodified lines
async def synthesize_tts(params: TTSParams = Depends()): try: # Validate text if not params.text.strip(): raise HTTPException( status_code=422, detail="Text parameter cannot be empty" )
# Validate temperature if not (0 <= params.temperature <= 1): raise HTTPException( status_code=422, detail="Temperature must be between 0 and 1" )
# Validate top_P if not (0 <= params.top_P <= 1): raise HTTPException(status_code=422, detail="top_P must be between 0 and 1")
# Validate top_K if params.top_K <= 0: raise HTTPException( status_code=422, detail="top_K must be a positive integer" ) if params.top_K > 100: raise HTTPException( status_code=422, detail="top_K must be less than or equal to 100" )
# Validate format if params.format not in ["mp3", "wav"]: raise HTTPException( status_code=422, detail="Invalid format. Supported formats are mp3 and wav", )
text = text_normalize(params.text, is_end=False)
calc_params = api_utils.calc_spk_style(spk=params.spk, style=params.style)37 unmodified lines import logging
logging.exception(e)
if isinstance(e, HTTPException): raise e else: raise HTTPException(status_code=500, detail=str(e)) raise HTTPException(status_code=500, detail=str(e))
def setup(api_manager: APIManager):78 unmodified lines79808182828384858687888978 unmodified lines params_infer_code["spk_emb"] = spk.emb logger.info(("spk", spk.name)) else: raise ValueError(f"spk must be int or Speaker, but: <{type(spk)}> {spk}") logger.warn( f"spk must be int or Speaker, but: <{type(spk)}> {spk}, wiil set to default voice" ) with SeedContext(2, True): params_infer_code["spk_emb"] = chat_tts.sample_random_speaker()
logger.info( {4 unmodified lines567891011121314148 unmodified lines1631641651661671681691704 unmodified linesfrom modules import modelsimport re
# 是否关闭 unk token 检查# NOTE: 单测的时候用于跳过模型加载DISABLE_UNK_TOKEN_CHECK = False
@lru_cache(maxsize=64)def is_chinese(text):148 unmodified lines """ 把不在字典里的字符替换为 " , " """ if DISABLE_UNK_TOKEN_CHECK: return text chat_tts = models.load_chat_tts() if "tokenizer" not in chat_tts.pretrain_models: # 这个地方只有在 huggingface spaces 中才会触发65 unmodified lines6667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931065 unmodified lines seed = random.randint(0, 2**32 - 1) attrs["seed"] = seed logger.info(f"random seed: {seed}")
class NotSupportSSML(Exception): pass
def parse_ssml(ssml: str) -> List[Dict[str, Any]]: root = etree.fromstring(ssml)
ssml_version = root.get("version", "NONE") if ssml_version != "0.1": raise NotSupportSSML("Unsupported ssml version: {ssml_version}")
segments = []
for voice in root.findall(".//voice"): voice_attrs = { "spk": voice.get("spk"), "style": voice.get("style"), "seed": voice.get("seed"), "top_p": voice.get("top_p"), "top_k": voice.get("top_k"), "temp": voice.get("temp"), "prompt1": voice.get("prompt1"), "prompt2": voice.get("prompt2"), "prefix": voice.get("prefix"), "normalize": voice.get("normalize"), }
voice_attrs = {k: v for k, v in voice_attrs.items() if v is not None}
expand_spk(voice_attrs) expand_style(voice_attrs)
merge_prompt(voice_attrs, voice) apply_random_seed(voice_attrs)
voice_segments = []
if voice_attrs.get("temp", "") == "min": # ref: https://github.com/2noise/ChatTTS/issues/123#issue-2326908144 voice_attrs["temp"] = 0.000000000001 if voice_attrs.get("temp", "") == "max": voice_attrs["temp"] = 1
# 处理 voice 开头的文本 if voice.text and voice.text.strip(): voice_segments.append( {"text": voice.text.strip(), "attrs": voice_attrs.copy()} )
# 处理 voice 内部的文本和 prosody 元素 for node in voice.iterchildren(): if node.tag == "prosody": prosody_attrs = voice_attrs.copy() new_attrs = { "rate": node.get("rate"), "volume": node.get("volume"), "pitch": node.get("pitch"), } prosody_attrs.update( {k: v for k, v in new_attrs.items() if v is not None} ) expand_style(prosody_attrs) merge_prompt(prosody_attrs, node) apply_random_seed(voice_attrs)
if node.text and node.text.strip(): voice_segments.append( {"text": node.text.strip(), "attrs": prosody_attrs} ) elif node.tag == "break": time_ms = int(node.get("time", "0").replace("ms", "")) segment = {"break": time_ms} voice_segments.append(segment)
if node.tail and node.tail.strip(): voice_segments.append( {"text": node.tail.strip(), "attrs": voice_attrs.copy()} )
end_segment = voice_segments[-1] end_segment["is_end"] = True
segments = segments + voice_segments
logger.info(f"collect len(segments): {len(segments)}") # logger.info(f"segments: {json.dumps(segments, ensure_ascii=False)}")
return segments
if __name__ == "__main__": # 示例 SSML 输入 ssml1 = """ <speak version="0.1"> <voice spk="20398768" seed="42" temp="min" top_p="0.9" top_k="20"> 电影中梁朝伟扮演的陈永仁的 <prosody volume="5"> 编号27149 </prosody> <prosody rate="2"> 编号27149 </prosody> <prosody pitch="-12"> 编号27149 </prosody> <prosody pitch="12"> 编号27149 </prosody> </voice> <voice spk="20398768" seed="42" speed="9"> 编号27149 </voice> <voice spk="20398768" seed="42"> 电影中梁朝伟扮演的陈永仁的编号27149 </voice> </speak> """
ssml2 = """ <speak version="0.1"> <voice spk="Bob"> 也可以合成多角色多情感的有声 [uv_break] 书 [uv_break] ,例如: </voice> <voice spk="Bob"> 黛玉冷笑道: </voice> <voice spk="female2"> 我说呢,亏了绊住,不然,早就飞了来了。 </voice> <voice spk="Bob" speed="0"> 宝玉道: </voice> <voice spk="Alice"> “只许和你玩,替你解闷。不过偶然到他那里,就说这些闲话。” </voice> <voice spk="female2"> “好没意思的话!去不去,关我什么事儿?又没叫你替我解闷儿,还许你不理我呢” </voice> <voice spk="Bob"> 说着,便赌气回房去了。 </voice> </speak> """ ssml22 = """<speak version="0.1"> <voice spk="Bob" style="narration-relaxed"> 下面是一个 ChatTTS 用于合成多角色多情感的有声书示例 </voice> <voice spk="Bob" style="narration-relaxed"> 黛玉冷笑道: </voice> <voice spk="female2" style="angry"> 我说呢 [uv_break] ,亏了绊住,不然,早就飞起来了。 </voice> <voice spk="Bob" style="narration-relaxed"> 宝玉道: </voice> <voice spk="Alice" style="unfriendly"> “只许和你玩 [uv_break] ,替你解闷。不过偶然到他那里,就说这些闲话。” </voice> <voice spk="female2" style="angry"> “好没意思的话![uv_break] 去不去,关我什么事儿? 又没叫你替我解闷儿 [uv_break],还许你不理我呢” </voice> <voice spk="Bob" style="narration-relaxed"> 说着,便赌气回房去了。 </voice></speak> """
ssml3 = """ <speak version="0.1"> <voice spk="Bob" style="angry"> “你到底在想什么?这已经是第三次了!每次我都告诉你要按时完成任务,可你总是拖延。你知道这对整个团队有多大的影响吗?!” </voice> <voice spk="Bob" style="assistant"> “你到底在想什么?这已经是第三次了!每次我都告诉你要按时完成任务,可你总是拖延。你知道这对整个团队有多大的影响吗?!” </voice> <voice spk="Bob" style="gentle"> “你到底在想什么?这已经是第三次了!每次我都告诉你要按时完成任务,可你总是拖延。你知道这对整个团队有多大的影响吗?!” </voice> </speak> """
ssml4 = """ <speak version="0.1"> <voice spk="Bob" style="narration-relaxed"> 使用 prosody 控制生成文本的语速语调和音量,示例如下
<prosody> 无任何限制将会继承父级voice配置进行生成 </prosody> <prosody rate="1.5"> 设置 rate 大于1表示加速,小于1为减速 </prosody> <prosody pitch="6"> 设置 pitch 调整音调,设置为6表示提高6个半音 </prosody> <prosody volume="2"> 设置 volume 调整音量,设置为2表示提高2个分贝 </prosody>
在 voice 中无prosody包裹的文本即为默认生成状态下的语音 </voice> </speak> """
ssml5 = """ <speak version="0.1"> <voice spk="Bob" style="narration-relaxed"> 使用 break 标签将会简单的 <break time="500" />
插入一段空白到生成结果中 </voice> </speak> """
ssml6 = """ <speak version="0.1"> <voice spk="Bob" style="excited"> temperature for sampling (may be overridden by style or speaker) <break time="500" /> 温度值用于采样,这个值有可能被 style 或者 speaker 覆盖 <break time="500" /> temperature for sampling ,这个值有可能被 style 或者 speaker 覆盖 <break time="500" /> 温度值用于采样,(may be overridden by style or speaker) </voice> </speak> """
segments = parse_ssml(ssml6)
print(segments)
# audio_segments = synthesize_segments(segments) # combined_audio = combine_audio_segments(audio_segments)
# combined_audio.export("output.wav", format="wav")28 unmodified lines29303132333435363738394049 unmodified lines90919287939495964 unmodified lines1011021039810410510610729 unmodified lines13713813913414014114214328 unmodified lines self.prompt2 = None self.prefix = None
def clone(self): ctx = SSMLContext() for k, v in self.items(): ctx[k] = v return ctx
class SSMLSegment(Box): def __init__(self, text: str, attrs=SSMLContext()):49 unmodified lines
@parser.resolver("speak") def tag_speak(element, context, segments, parser): ctx = copy.deepcopy(context) ctx = context.clone() if context is not None else SSMLContext()
version = element.get("version") if version != "0.1":4 unmodified lines
@parser.resolver("voice") def tag_voice(element, context, segments, parser): ctx = copy.deepcopy(context) ctx = context.clone() if context is not None else SSMLContext()
ctx.spk = element.get("spk", ctx.spk) ctx.style = element.get("style", ctx.style)29 unmodified lines
@parser.resolver("prosody") def tag_prosody(element, context, segments, parser): ctx = copy.deepcopy(context) ctx = context.clone() if context is not None else SSMLContext()
ctx.spk = element.get("spk", ctx.spk) ctx.style = element.get("style", ctx.style)1 unmodified line2345678910111213141516171819202122232425266 unmodified lines333435363738394016 unmodified lines57585960616263641 unmodified lineimport osimport subprocess
from modules.utils import constants
# 用于判断是否在hf spacestry: import spacesexcept: spaces = None
git = os.environ.get("GIT", "git")
in_hf_spaces = spaces is not None
@lru_cache()def commit_hash(): try: if in_hf_spaces: return "<hf>" return subprocess.check_output( [git, "-C", constants.ROOT_DIR, "rev-parse", "HEAD"], shell=False,6 unmodified lines@lru_cache()def git_tag(): try: if in_hf_spaces: return "<hf>" return subprocess.check_output( [git, "-C", constants.ROOT_DIR, "describe", "--tags"], shell=False,16 unmodified lines@lru_cache()def branch_name(): try: if in_hf_spaces: return "<hf>" return subprocess.check_output( [git, "-C", constants.ROOT_DIR, "rev-parse", "--abbrev-ref", "HEAD"], shell=False,45 unmodified lines4647484950515253545517 unmodified lines73747576777879808145 unmodified lines # remove code return ""
def thematic_break(self) -> str: # remove break return "\n"
def markdown_to_text(markdown_text): renderer = PlainTextRenderer()17 unmodified lines- 列表项 2- 列表项 3
1. 第一2. 第二
> 这是一个引用。
`代码片段`12345678916 unmodified lines262728293031282932333431353637383940import jsonimport osimport gradio as grimport logging
logger = logging.getLogger(__name__)
current_translation = {}localization_root = os.path.join(16 unmodified lines assert isinstance(v, str) or isinstance( v, list ), f"Value for key {k} is not a string or list"
logger.info(f"Loaded localization file {full_name}") except Exception as e: print(str(e)) print(f"Failed to load localization file {full_name}") logger.warning(str(e)) logger.warning(f"Failed to load localization file {full_name}") else: print(f"Localization file {full_name} not found") logger.warning(f"Localization file {full_name} does not exist") else: logger.warning(f"Localization file {filename} is not a string")
# current_translation = {k: 'XXX' for k in current_translation.keys()} # use this to see if all texts are covered
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import gradio as grimport torchfrom modules.speaker import Speakerfrom modules.hf import spacesfrom modules.webui import webui_configfrom modules.webui.webui_utils import tts_generate
import tempfile
@torch.inference_mode()@spaces.GPUdef test_spk_voice(spk_file, text: str): if spk_file == "" or spk_file is None: return None spk = Speaker.from_file(spk_file) return tts_generate( spk=spk, text=text, )
def speaker_editor_ui(): def on_generate(spk_file, name, gender, desc): spk: Speaker = Speaker.from_file(spk_file) spk.name = name spk.gender = gender spk.desc = desc
with tempfile.NamedTemporaryFile(delete=False, suffix=".pt") as tmp_file: torch.save(spk, tmp_file) tmp_file_path = tmp_file.name
return tmp_file_path
def create_test_voice_card(spk_file): with gr.Group(): gr.Markdown("🎤Test voice") with gr.Row(): test_voice_btn = gr.Button( "Test Voice", variant="secondary", interactive=False )
with gr.Column(scale=4): test_text = gr.Textbox( label="Test Text", placeholder="Please input test text", value=webui_config.localization.DEFAULT_SPEAKER_TEST_TEXT, ) with gr.Row(): with gr.Column(scale=4): output_audio = gr.Audio(label="Output Audio", format="mp3")
test_voice_btn.click( fn=test_spk_voice, inputs=[spk_file, test_text], outputs=[output_audio], )
return test_voice_btn
has_file = gr.State(False)
# TODO 也许需要写个说明? # gr.Markdown("SPEAKER_CREATOR_GUIDE")
with gr.Row(): with gr.Column(scale=2): with gr.Group(): gr.Markdown("💼Speaker file") spk_file = gr.File(label="*.pt file", file_types=[".pt"])
with gr.Group(): gr.Markdown("ℹ️Speaker info") name_input = gr.Textbox( label="Name", placeholder="Enter speaker name", value="*", interactive=False, ) gender_input = gr.Textbox( label="Gender", placeholder="Enter gender", value="*", interactive=False, ) desc_input = gr.Textbox( label="Description", placeholder="Enter description", value="*", interactive=False, ) with gr.Group(): gr.Markdown("🔊Generate speaker.pt") generate_button = gr.Button("Save .pt file", interactive=False) output_file = gr.File(label="Save to File") with gr.Column(scale=5): btn1 = create_test_voice_card(spk_file=spk_file) btn2 = create_test_voice_card(spk_file=spk_file) btn3 = create_test_voice_card(spk_file=spk_file) btn4 = create_test_voice_card(spk_file=spk_file)
generate_button.click( fn=on_generate, inputs=[spk_file, name_input, gender_input, desc_input], outputs=[output_file], )
def spk_file_change(spk_file): empty = spk_file is None or spk_file == "" if empty: return [ gr.Textbox(value="*", interactive=False), gr.Textbox(value="*", interactive=False), gr.Textbox(value="*", interactive=False), gr.Button(interactive=False), gr.Button(interactive=False), gr.Button(interactive=False), gr.Button(interactive=False), gr.Button(interactive=False), ] spk: Speaker = Speaker.from_file(spk_file) return [ gr.Textbox(value=spk.name, interactive=True), gr.Textbox(value=spk.gender, interactive=True), gr.Textbox(value=spk.describe, interactive=True), gr.Button(interactive=True), gr.Button(interactive=True), gr.Button(interactive=True), gr.Button(interactive=True), gr.Button(interactive=True), ]
spk_file.change( fn=spk_file_change, inputs=[spk_file], outputs=[ name_input, gender_input, desc_input, generate_button, btn1, btn2, btn3, btn4, ], )1234561 unmodified line89101112131415import gradio as gr
from modules.webui.speaker.speaker_editor import speaker_editor_uifrom modules.webui.speaker.speaker_merger import create_speaker_mergerfrom modules.webui.speaker.speaker_creator import speaker_creator_ui
1 unmodified linedef create_speaker_panel():
with gr.Tabs(): with gr.Tab("Editor"): speaker_editor_ui() with gr.TabItem("Creator"): speaker_creator_ui() with gr.TabItem("Merger"):6 unmodified lines78910111011121314151617181920212223241516252627282930212231323334353627283738394041423334434445464748495051525354555657363758596041426162636465664748676869707159 unmodified lines1311321331141341351361371381391401416 unmodified linesfrom modules.hf import spaces
podcast_default_case = [ [1, "female2", "你好,欢迎收听今天的播客内容。今天我们要聊的是中华料理。", "chat"], [2, "Alice", "嗨,我特别期待这个话题!中华料理真的是博大精深。", "chat"], [ 1, "female2", "你好,欢迎收听今天的播客内容。今天我们要聊的是中华料理。 [lbreak]", "podcast_p", ], [ 2, "Alice", "嗨,我特别期待这个话题!中华料理真的是博大精深。 [lbreak]", "podcast_p", ], [ 3, "Bob", "没错,中华料理有着几千年的历史,而且每个地区都有自己的特色菜。", "chat", "没错,中华料理有着几千年的历史,而且每个地区都有自己的特色菜。 [lbreak]", "podcast_p", ], [ 4, "female2", "那我们先从最有名的川菜开始吧。川菜以其麻辣著称,是很多人的最爱。", "chat", "那我们先从最有名的川菜开始吧。川菜以其麻辣著称,是很多人的最爱。 [lbreak]", "podcast_p", ], [ 5, "Alice", "对,我特别喜欢吃麻婆豆腐和辣子鸡。那种麻辣的感觉真是让人难以忘怀。", "chat", "对,我特别喜欢吃麻婆豆腐和辣子鸡。那种麻辣的感觉真是让人难以忘怀。 [lbreak]", "podcast_p", ], [ 6, "Bob", "除了川菜,粤菜也是很受欢迎的。粤菜讲究鲜美,像是白切鸡和蒸鱼都是经典。", "chat", "除了川菜,粤菜也是很受欢迎的。粤菜讲究鲜美,像是白切鸡和蒸鱼都是经典。 [lbreak]", "podcast_p", ], [ 7, "female2", "对啊,粤菜的烹饪方式比较清淡,更注重食材本身的味道。 [lbreak]", "podcast_p", ], [ 8, "Alice", "还有北京的京菜,像北京烤鸭,那可是来北京必吃的美食。 [lbreak]", "podcast_p", ], [7, "female2", "对啊,粤菜的烹饪方式比较清淡,更注重食材本身的味道。", "chat"], [8, "Alice", "还有北京的京菜,像北京烤鸭,那可是来北京必吃的美食。", "chat"], [ 9, "Bob", "不仅如此,还有淮扬菜、湘菜、鲁菜等等,每个菜系都有其独特的风味。", "chat", "不仅如此,还有淮扬菜、湘菜、鲁菜等等,每个菜系都有其独特的风味。 [lbreak]", "podcast_p", ], [ 10, "female2", "对对对,像淮扬菜的狮子头,湘菜的剁椒鱼头,都是让人垂涎三尺的美味。", "chat", "对对对,像淮扬菜的狮子头,湘菜的剁椒鱼头,都是让人垂涎三尺的美味。 [lbreak]", "podcast_p", ],]
59 unmodified lines script_table = gr.DataFrame( headers=["index", "speaker", "text", "style"], datatype=["number", "str", "str", "str"], interactive=False, interactive=True, wrap=True, value=podcast_default_case, row_count=(0, "dynamic"), col_count=(4, "fixed"), )
send_to_ssml_btn = gr.Button("📩Send to SSML", variant="primary")90 unmodified lines9192939494959697989990 unmodified lines )
with gr.Tab(label="Upload"): spk_file_upload = gr.File(label="Speaker (Upload)") spk_file_upload = gr.File( label="Speaker (Upload)", file_types=[".pt"] )
gr.Markdown("📝Speaker info") infos = gr.Markdown("empty")92 unmodified lines939495969697989910010110210110210392 unmodified lines tensor = torch.from_numpy(audio_data).float().squeeze().cpu() enhancer = load_enhancer(device)
if enable_enhance: if enable_enhance or enable_denoise: lambd = 0.9 if enable_denoise else 0.1 tensor, sr = enhancer.enhance( tensor, sr, tau=0.5, nfe=64, solver="rk4", lambd=lambd, device=device ) elif enable_denoise: tensor, sr = enhancer.denoise(tensor, sr)
audio_data = tensor.cpu().numpy() return audio_data, int(sr)83 unmodified lines8485868787888915 unmodified lines1051061071091081091101112 unmodified lines11411511611811911711811983 unmodified lines parser.add_argument( "--language", type=str, default="zh-CN", help="Set the default language for the webui", ) args = parser.parse_args()15 unmodified lines device_id = get_and_update_env(args, "device_id", None, str) use_cpu = get_and_update_env(args, "use_cpu", [], list) compile = get_and_update_env(args, "compile", False, bool) language = get_and_update_env(args, "language", False, bool) language = get_and_update_env(args, "language", "zh-CN", str)
webui_config.experimental = get_and_update_env( args, "webui_experimental", False, bool2 unmodified lines webui_config.ssml_max = get_and_update_env(args, "ssml_max_len", 5000, int) webui_config.max_batch_size = get_and_update_env(args, "max_batch_size", 8, int)
config.runtime_env_vars.language = "zh-CN"
webui_init() demo = create_interface()
language/zh-CN.json+3-2
modules/api/impl/google_api.py+12-6
modules/api/impl/openai_api.py+5-1
modules/api/impl/refiner_api.py+5-1
modules/api/impl/ssml_api.py+15-5
modules/api/impl/tts_api.py+38-1
modules/generate_audio.py+5-1
modules/normalization.py+6
modules/ssml.py-242
modules/ssml_parser/SSMLParser.py+9-3
modules/utils/git.py+15
modules/utils/markdown.py+7
modules/webui/localization.py+9-3
modules/webui/speaker/speaker_editor.pyAdded+147
modules/webui/speaker_tab.py+3
modules/webui/ssml/podcast_tab.py+38-17
modules/webui/tts_tab.py+3-1
modules/webui/webui_utils.py+1-3
webui.py+1-4