Skip to content

Commit

Permalink
Merge pull request #1043 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
优化:edge-tts新增代理地址设置。edge-tts函数传参优化;新增:文本转语音 新增 不启用类型,可以不进行TTS合成喵;文档:更新投资人
  • Loading branch information
Ikaros-521 authored Oct 30, 2024
2 parents 0b543ed + 606f89f commit 0ff1350
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@
"edge-tts": {
"voice": "zh-CN-XiaoyiNeural",
"rate": "+0%",
"volume": "+0%"
"volume": "+0%",
"proxy": ""
},
"elevenlabs": {
"api_key": "",
Expand Down
3 changes: 2 additions & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@
"edge-tts": {
"voice": "zh-CN-XiaoyiNeural",
"rate": "+0%",
"volume": "+0%"
"volume": "+0%",
"proxy": ""
},
"elevenlabs": {
"api_key": "",
Expand Down
10 changes: 10 additions & 0 deletions docs/投资人/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,16 @@
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_241023160441_QQ%E5%9B%BE%E7%89%8720241024000339.jpg",
amount: "28.8"
},
{
name: "Lucas",
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_241030144848_QQ%E5%9B%BE%E7%89%8720241030224840.jpg",
amount: "10"
},
{
name: "精品小芒果",
avatar: "https://images.cnblogs.com/cnblogs_com/ikaros-521/2328032/o_241030150708_QQ%E5%9B%BE%E7%89%8720241030230648.png",
amount: "5"
},
];

// 对投资方数据按投资金额(amount)进行降序排序
Expand Down
Binary file modified docs/投资人/invest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ def audio_synthesis(self, message):
try:
logger.debug(message)

# TTS类型为 none 时不合成音频
if self.config.get("audio_synthesis_type") == "none":
return

# 将用户名字符串中的数字转换成中文
if self.config.get("filter", "username_convert_digits_to_chinese"):
if message["username"] is not None:
Expand Down Expand Up @@ -967,9 +971,7 @@ async def tts_handle(self, message):
elif message["tts_type"] == "edge-tts":
data = {
"content": message["content"],
"voice": message["data"]["voice"],
"rate": message["data"]["rate"],
"volume": message["data"]["volume"]
"edge-tts": message["data"]
}

# 调用接口合成语音
Expand Down Expand Up @@ -1862,7 +1864,6 @@ async def audio_synthesis_use_local_config(self, content, audio_synthesis_type="

vits = self.config.get("vits")
vits_fast = self.config.get("vits_fast")
edge_tts_config = self.config.get("edge-tts")
bark_gui = self.config.get("bark_gui")
vall_e_x = self.config.get("vall_e_x")
openai_tts = self.config.get("openai_tts")
Expand Down Expand Up @@ -1966,9 +1967,7 @@ async def audio_synthesis_use_local_config(self, content, audio_synthesis_type="
elif audio_synthesis_type == "edge-tts":
data = {
"content": content,
"voice": edge_tts_config["voice"],
"rate": edge_tts_config["rate"],
"volume": edge_tts_config["volume"]
"edge-tts": self.config.get("edge-tts")
}

# 调用接口合成语音
Expand Down
11 changes: 10 additions & 1 deletion utils/audio_handle/my_tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,17 @@ async def edge_tts_api(self, data):
# voice_tmp_path = './out/' + self.common.get_bj_time(4) + '.mp3'
# 过滤" '字符
data["content"] = data["content"].replace('"', '').replace("'", '')

proxy = data["edge-tts"]["proxy"] if data["edge-tts"]["proxy"] != "" else None

# 使用 Edge TTS 生成回复消息的语音文件
communicate = edge_tts.Communicate(text=data["content"], voice=data["voice"], rate=data["rate"], volume=data["volume"])
communicate = edge_tts.Communicate(
text=data["content"],
voice=data["edge-tts"]["voice"],
rate=data["edge-tts"]["rate"],
volume=data["edge-tts"]["volume"],
proxy=proxy
)
await communicate.save(voice_tmp_path)

return voice_tmp_path
Expand Down
9 changes: 6 additions & 3 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2504,6 +2504,7 @@ def update_config(config_mapping, config, config_data, type="common_config"):
"voice": (select_edge_tts_voice, 'str'),
"rate": (input_edge_tts_rate, 'str'),
"volume": (input_edge_tts_volume, 'str'),
"proxy": (input_edge_tts_proxy, 'str'),
},
"vits": {
"type": (select_vits_type, 'str'),
Expand Down Expand Up @@ -3368,6 +3369,7 @@ def save_config():

# 语音合成所有配置项
audio_synthesis_type_options = {
'none': '不启用',
'edge-tts': 'Edge-TTS',
'vits': 'VITS',
'bert_vits2': 'bert_vits2',
Expand Down Expand Up @@ -5380,10 +5382,11 @@ def clear_tts_common_audio_card(file_path):
value=config.get("edge-tts", "voice")
)

input_edge_tts_rate = ui.input(label='语速增益', placeholder='语速增益 默认是 +0%,可以增减,注意 + - %符合别搞没了,不然会影响语音合成', value=config.get("edge-tts", "rate")).style("width:200px;")
input_edge_tts_rate = ui.input(label='语速增益', placeholder='语速增益 默认是 +0%,可以增减,注意 + - %符合别搞没了,不然会影响语音合成', value=config.get("edge-tts", "rate")).style("width:150px;").tooltip("语速增益 默认是 +0%,可以增减,注意 + - %符合别搞没了,不然会影响语音合成")

input_edge_tts_volume = ui.input(label='音量增益', placeholder='音量增益 默认是 +0%,可以增减,注意 + - %符合别搞没了,不然会影响语音合成', value=config.get("edge-tts", "volume")).style("width:200px;")

input_edge_tts_volume = ui.input(label='音量增益', placeholder='音量增益 默认是 +0%,可以增减,注意 + - %符合别搞没了,不然会影响语音合成', value=config.get("edge-tts", "volume")).style("width:150px;").tooltip("音量增益 默认是 +0%,可以增减,注意 + - %符合别搞没了,不然会影响语音合成")
input_edge_tts_proxy = ui.input(label='HTTP代理地址', placeholder='例:http://127.0.0.1:10809', value=config.get("edge-tts", "proxy")).style("width:300px;").tooltip("根据您的实际代理配置,例:http://127.0.0.1:10809")

if config.get("webui", "show_card", "tts", "vits"):
with ui.card().style(card_css):
ui.label("VITS-Simple-API")
Expand Down

0 comments on commit 0ff1350

Please sign in to comment.