Skip to content

Commit

Permalink
ChatTTS gradio新增 0621版的兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikaros-521 committed Jun 21, 2024
1 parent 315498a commit f16cf3f
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,6 @@ main copy.py

data/*.db

locales
locales

dy2.py
10 changes: 7 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,15 @@
}
},
"chattts": {
"type": "gradio",
"api_ip_port": "http://127.0.0.1:58081",
"type": "gradio_0621",
"api_ip_port": "http://127.0.0.1:9880",
"gradio_ip_port": "http://127.0.0.1:58081",
"temperature": 0.3,
"audio_seed_input": 1,
"audio_seed_input": 2,
"top_p": 0.7,
"top_k": 20,
"text_seed_input": 42,
"refine_text_flag": true,
"api": {
"media_type": "wav",
"seed": 2581,
Expand Down
10 changes: 7 additions & 3 deletions config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -833,11 +833,15 @@
}
},
"chattts": {
"type": "gradio",
"api_ip_port": "http://127.0.0.1:58081",
"type": "gradio_0621",
"api_ip_port": "http://127.0.0.1:9880",
"gradio_ip_port": "http://127.0.0.1:58081",
"temperature": 0.3,
"audio_seed_input": 1,
"audio_seed_input": 2,
"top_p": 0.7,
"top_k": 20,
"text_seed_input": 42,
"refine_text_flag": true,
"api": {
"media_type": "wav",
"seed": 2581,
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ slack_sdk==3.21.3
profanity==1.1
elevenlabs==0.2.8
PyPDF2
protobuf
protobuf_inspector
websocket-client
websocket-client-py3
Expand Down
21 changes: 21 additions & 0 deletions utils/audio_handle/my_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,27 @@ async def chattts_api(self, data):

new_file_path = None

if result:
voice_tmp_path = result[0]
new_file_path = self.common.move_file(voice_tmp_path, os.path.join(self.audio_out_path, 'chattts_' + self.common.get_bj_time(4)), 'chattts_' + self.common.get_bj_time(4))

return new_file_path
elif data["type"] == "gradio_0621":
client = Client(data["gradio_ip_port"])

result = client.predict(
text=data["content"], # str in '需要合成的文本' Textbox component
temperature=data["temperature"], # 越大越发散,越小越保守
top_P=data["top_p"],
top_K=data["top_k"],
audio_seed_input=int(data["audio_seed_input"]), # 声音种子
text_seed_input=int(data["text_seed_input"]),
refine_text_flag=data["refine_text_flag"],
api_name="/generate_audio"
)

new_file_path = None

if result:
voice_tmp_path = result[0]
new_file_path = self.common.move_file(voice_tmp_path, os.path.join(self.audio_out_path, 'chattts_' + self.common.get_bj_time(4)), 'chattts_' + self.common.get_bj_time(4))
Expand Down
12 changes: 11 additions & 1 deletion webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2359,6 +2359,11 @@ def common_textarea_handle(content):
config_data["chattts"]["gradio_ip_port"] = input_chattts_gradio_ip_port.value
config_data["chattts"]["temperature"] = round(float(input_chattts_temperature.value), 2)
config_data["chattts"]["audio_seed_input"] = int(input_chattts_audio_seed_input.value)
config_data["chattts"]["top_p"] = round(float(input_chattts_top_p.value), 2)
config_data["chattts"]["top_k"] = int(input_chattts_top_k.value)
config_data["chattts"]["text_seed_input"] = int(input_chattts_text_seed_input.value)
config_data["chattts"]["refine_text_flag"] = switch_chattts_refine_text_flag.value

config_data["chattts"]["api"]["seed"] = int(input_chattts_api_seed.value)
config_data["chattts"]["api"]["media_type"] = input_chattts_api_media_type.value

Expand Down Expand Up @@ -5218,7 +5223,7 @@ async def fish_speech_load_model(data):
with ui.row():
select_chattts_type = ui.select(
label='类型',
options={"api": "api", "gradio": "gradio"},
options={"api": "api", "gradio_0621": "gradio_0621", "gradio": "gradio"},
value=config.get("chattts", "type")
).style("width:150px").tooltip("对接的API类型")
input_chattts_api_ip_port = ui.input(
Expand All @@ -5239,6 +5244,11 @@ async def fish_speech_load_model(data):
).style("width:200px;").tooltip("对接旧版webui的gradio接口,填webui的地址")
input_chattts_temperature = ui.input(label='温度', value=config.get("chattts", "temperature"), placeholder='默认:0.3').style("width:200px;").tooltip("Audio temperature,越大越发散,越小越保守")
input_chattts_audio_seed_input = ui.input(label='声音种子', value=config.get("chattts", "audio_seed_input"), placeholder='默认:-1').style("width:200px;").tooltip("声音种子,-1随机,1女生,4女生,8男生")
input_chattts_top_p = ui.input(label='top_p', value=config.get("chattts", "top_p"), placeholder='默认:0.7').style("width:200px;").tooltip("top_p")
input_chattts_top_k = ui.input(label='top_k', value=config.get("chattts", "top_k"), placeholder='默认:20').style("width:200px;").tooltip("top_k")
input_chattts_text_seed_input = ui.input(label='text_seed_input', value=config.get("chattts", "text_seed_input"), placeholder='默认:42').style("width:200px;").tooltip("text_seed_input")
switch_chattts_refine_text_flag = ui.switch('自动播放', value=config.get("chattts", "refine_text_flag")).style(switch_internal_css)

with ui.card().style(card_css):
ui.label("API相关配置")
with ui.row():
Expand Down

0 comments on commit f16cf3f

Please sign in to comment.