Skip to content

Commit

Permalink
Merge pull request #632 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
文案页-文案音频合成新增语音合成类型选择,可以自定义TTS进行合成,不需要保存就可以切换
  • Loading branch information
Ikaros-521 committed Feb 11, 2024
2 parents e011ced + 4de7fd2 commit fdb58aa
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@

### 合作伙伴

智来星球:[m.zlxqai.com](http://m.zlxqai.com/) ———— 提供GPT、AI绘图服务

青椒云:[qingjiaocloud.com](https://account.qingjiaocloud.com/signin?inviteCode=4Q92ROBQ) ———— AIGC 高性能云桌面

睿声AI:[reecho.ai](https://www.reecho.ai/) ———— 瞬时创建 超级拟真的 人工智能克隆语音
Expand Down
1 change: 1 addition & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@
"copywriting": {
"text_path": "data/copywriting/test.txt",
"audio_save_path": "out/copywriting/",
"audio_synthesis_type": "edge-tts",
"config": [
{
"file_path": "data/copywriting/",
Expand Down
1 change: 1 addition & 0 deletions config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@
"copywriting": {
"text_path": "data/copywriting/test.txt",
"audio_save_path": "out/copywriting/",
"audio_synthesis_type": "edge-tts",
"config": [
{
"file_path": "data/copywriting/",
Expand Down
Binary file modified out/copywriting/test.wav
Binary file not shown.
19 changes: 16 additions & 3 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1220,11 +1220,24 @@ def merge_audio_files(self, directory, base_filename, last_index, pause_duration


# 只进行文案音频合成
async def copywriting_synthesis_audio(self, file_path, out_audio_path="out/"):
async def copywriting_synthesis_audio(self, file_path, out_audio_path="out/", audio_synthesis_type="edge-tts"):
"""文案音频合成
Args:
file_path (str): 文案文本文件路径
out_audio_path (str, optional): 音频输出的文件夹路径. Defaults to "out/".
audio_synthesis_type (str, optional): 语音合成类型. Defaults to "edge-tts".
Raises:
Exception: _description_
Exception: _description_
Returns:
str: 合成完毕的音频路径
"""
try:
max_len = self.config.get("filter", "max_len")
max_char_len = self.config.get("filter", "max_char_len")
audio_synthesis_type = self.config.get("audio_synthesis_type")
vits = self.config.get("vits")
vits_fast = self.config.get("vits_fast")
edge_tts_config = self.config.get("edge-tts")
Expand Down Expand Up @@ -1520,7 +1533,7 @@ async def voice_change_and_put_to_queue(voice_tmp_path):
}

# 调用接口合成语音
voice_tmp_path = await self.my_tts.clone_voice_api(content)
voice_tmp_path = await self.my_tts.clone_voice_api(data)

if voice_tmp_path is None:
raise Exception(f"{audio_synthesis_type}合成失败")
Expand Down
24 changes: 23 additions & 1 deletion webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,9 @@ async def copywriting_audio_synthesis():

copywriting_text_path = input_copywriting_text_path.value
copywriting_audio_save_path = input_copywriting_audio_save_path.value
audio_synthesis_type = select_copywriting_audio_synthesis_type.value

file_path = await audio.copywriting_synthesis_audio(copywriting_text_path, copywriting_audio_save_path)
file_path = await audio.copywriting_synthesis_audio(copywriting_text_path, copywriting_audio_save_path, audio_synthesis_type)

if file_path:
ui.notify(position="top", type="positive", message=f"文案音频合成成功,存储于:{file_path}")
Expand Down Expand Up @@ -1332,6 +1333,7 @@ def common_textarea_handle(content):
config_data["copywriting"]["switching_interval"] = input_copywriting_switching_interval.value
config_data["copywriting"]["text_path"] = input_copywriting_text_path.value
config_data["copywriting"]["audio_save_path"] = input_copywriting_audio_save_path.value
config_data["copywriting"]["audio_synthesis_type"] = select_copywriting_audio_synthesis_type.value

tmp_arr = []
# logging.info(copywriting_config_var)
Expand Down Expand Up @@ -3035,6 +3037,26 @@ def common_textarea_handle(content):
button_copywriting_text_load = ui.button('加载文本', on_click=copywriting_text_load, color=button_internal_color).style(button_internal_css)
input_copywriting_audio_save_path = ui.input(label='音频存储路径', value=config.get("copywriting", "audio_save_path"), placeholder='音频合成后存储的路径').style("width:250px;")
# input_copywriting_chunking_stop_time = ui.input(label='断句停顿时长', value=config.get("copywriting", "chunking_stop_time"), placeholder='自动根据标点断句后,2个句子之间的无声时长').style("width:150px;")
select_copywriting_audio_synthesis_type = ui.select(
label='语音合成',
options={
'edge-tts': 'Edge-TTS',
'vits': 'VITS',
'bert_vits2': 'bert_vits2',
'vits_fast': 'VITS-Fast',
'elevenlabs': 'elevenlabs',
'genshinvoice_top': 'genshinvoice_top',
'tts_ai_lab_top': 'tts_ai_lab_top',
'bark_gui': 'bark_gui',
'vall_e_x': 'VALL-E-X',
'openai_tts': 'OpenAI TTS',
'reecho_ai': '睿声AI',
'gradio_tts': 'Gradio',
'gpt_sovits': 'GPT_SoVITS',
'clone_voice': 'clone-voice'
},
value=config.get("copywriting", "audio_synthesis_type")
).style("width:200px;")
with ui.row():
textarea_copywriting_text = ui.textarea(label='文案文本', value='', placeholder='此处对需要合成文案音频的文本内容进行编辑。文案会自动根据逻辑进行切分,然后根据配置合成完整的一个音频文件。').style("width:1000px;")
with ui.row():
Expand Down

0 comments on commit fdb58aa

Please sign in to comment.