diff --git a/README.md b/README.md index a1e2c497..16a89c98 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ `Luna AI` 的外观由 `Live2D、Vtube Studio、xuniren、UE5 结合 Audio2Face、EasyAIVtuber、数字人视频播放器(Easy-Wav2Lip)` 技术打造,为用户提供了一个生动、互动的虚拟形象。这使得 `Luna AI` 能够在各大直播平台,如 `Bilibili、抖音、快手、微信视频号、斗鱼、YouTube、Twitch 和 TikTok`,进行实时互动直播。当然,它也可以在本地环境中与您进行个性化对话。 -为了使交流更加自然,`Luna AI` 使用了先进的自然语言处理技术,结合文本转语音系统,如 `Edge-TTS、VITS-Fast、elevenlabs、bark-gui、VALL-E-X、睿声AI、genshinvoice.top、tts.ai-lab.top、OpenVoice、GPT_SoVITS、clone-voice、Azure TTS`。这不仅让它能够生成流畅的回答,还可以通过 `so-vits-svc 和 DDSP-SVC` 实现声音的变化,以适应不同的场景和角色。 +为了使交流更加自然,`Luna AI` 使用了先进的自然语言处理技术,结合文本转语音系统,如 `Edge-TTS、VITS-Fast、elevenlabs、bark-gui、VALL-E-X、睿声AI、genshinvoice.top、tts.ai-lab.top、OpenVoice、GPT_SoVITS、clone-voice、Azure TTS、fish-speech`。这不仅让它能够生成流畅的回答,还可以通过 `so-vits-svc 和 DDSP-SVC` 实现声音的变化,以适应不同的场景和角色。 此外,`Luna AI` 还能够通过特定指令与 `Stable Diffusion` 协作,展示画作。用户还可以自定义文案,让 Luna AI 循环播放,以满足不同场合的需求。 diff --git a/main.py b/main.py index 8f571b15..8ab3c753 100644 --- a/main.py +++ b/main.py @@ -1256,12 +1256,16 @@ def _on_open_live_danmaku(self, client: blivedm.OpenLiveClient, message: open_mo # logging.info(f'[{client.room_id}] {message.uname}:{message.msg}') content = message.msg # 获取弹幕内容 username = message.uname # 获取发送弹幕的用户昵称 + user_face = message.uface + + logging.debug(f"用户:{username} 头像:{user_face}") logging.info(f"[{username}]: {content}") data = { "platform": platform, "username": username, + "uface": user_face, "content": content } diff --git a/utils/audio_handle/my_tts.py b/utils/audio_handle/my_tts.py index 5c88ba9c..9c17c472 100644 --- a/utils/audio_handle/my_tts.py +++ b/utils/audio_handle/my_tts.py @@ -5,6 +5,7 @@ import traceback import edge_tts from urllib.parse import urljoin +import random from utils.common import Common from utils.logger import Configure_logger @@ -43,6 +44,17 @@ def __init__(self, config_path): logging.error("请检查播放音频的音频输出路径配置!!!这将影响程序使用!") + # 获取随机数,单数据就是原数值,有-则判断为范围性数据,随机一个数值,返回float数据 + def get_random_float(self, data): + # 将非字符串的情况统一处理为长度相同的最小值和最大值 + if isinstance(data, str) and "-" in data: + min, max = map(float, data.split("-")) + else: + min = max = float(data) + + # 返回指定范围内的随机浮点数 + return random.uniform(min, max) + # 请求vits的api async def vits_api(self, data): try: @@ -76,16 +88,17 @@ async def vits_api(self, data): elif data["type"] == "bert_vits2": # API地址 "http://127.0.0.1:23456/voice/bert-vits2" API_URL = urljoin(data["api_ip_port"], '/voice/bert-vits2') + data_json = { "text": data["content"], "id": data["id"], "format": data["format"], "lang": "ja", - "length": data["length"], - "noise": data["noise"], - "noisew": data["noisew"], + "length": self.get_random_float(data["length"]), + "noise": self.get_random_float(data["noise"]), + "noisew": self.get_random_float(data["noisew"]), "max": data["max"], - "sdp_radio": data["sdp_radio"] + "sdp_radio": self.get_random_float(data["sdp_radio"]) } if data["lang"] == "中文" or data["lang"] == "汉语": @@ -141,18 +154,18 @@ async def bert_vits2_api(self, data): "speaker_name": data["speaker_name"], "speaker_id": data["speaker_id"], "language": data["language"], - "length": data["length"], - "noise": data["noise"], - "noisew": data["noisew"], - "sdp_radio": data["sdp_radio"], + "length": self.get_random_float(data["length"]), + "noise": self.get_random_float(data["noise"]), + "noisew": self.get_random_float(data["noisew"]), + "sdp_radio": self.get_random_float(data["sdp_radio"]), "auto_translate": data["auto_translate"], "auto_split": data["auto_split"], "emotion": data["emotion"], "style_text": data["style_text"], - "style_weight": data["style_weight"] + "style_weight": self.get_random_float(data["style_weight"]) } - # logging.info(f"data_json={data_json}") + logging.debug(f"data_json={data_json}") # logging.info(f"data={data}") logging.debug(f"API_URL={API_URL}") @@ -642,6 +655,7 @@ async def websocket_client_logic(websocket, data_json): if key != "api_ip_port" } + params["speed"] = self.get_random_float(params["speed"]) params["text"] = data["content"] async with aiohttp.ClientSession() as session: diff --git a/webui.py b/webui.py index 2d47a20f..8528c5a7 100644 --- a/webui.py +++ b/webui.py @@ -1041,7 +1041,6 @@ def common_textarea_handle(content): config_data["claude"]["slack_user_token"] = input_claude_slack_user_token.value config_data["claude"]["bot_user_id"] = input_claude_bot_user_id.value - if config.get("webui", "show_card", "llm", "claude2"): config_data["claude2"]["cookie"] = input_claude2_cookie.value config_data["claude2"]["use_proxy"] = switch_claude2_use_proxy.value config_data["claude2"]["proxies"]["http"] = input_claude2_proxies_http.value @@ -1277,13 +1276,13 @@ def common_textarea_handle(content): config_data["bert_vits2"]["speaker_name"] = input_vits_speaker_name.value config_data["bert_vits2"]["speaker_id"] = int(input_vits_speaker_id.value) config_data["bert_vits2"]["language"] = select_bert_vits2_language.value - config_data["bert_vits2"]["length"] = round(float(input_bert_vits2_length.value), 2) - config_data["bert_vits2"]["noise"] = round(float(input_bert_vits2_noise.value), 2) - config_data["bert_vits2"]["noisew"] = round(float(input_bert_vits2_noisew.value), 2) - config_data["bert_vits2"]["sdp_radio"] = round(float(input_bert_vits2_sdp_radio.value), 2) + config_data["bert_vits2"]["length"] = input_bert_vits2_length.value + config_data["bert_vits2"]["noise"] = input_bert_vits2_noise.value + config_data["bert_vits2"]["noisew"] = input_bert_vits2_noisew.value + config_data["bert_vits2"]["sdp_radio"] = input_bert_vits2_sdp_radio.value config_data["bert_vits2"]["emotion"] = input_bert_vits2_emotion.value config_data["bert_vits2"]["style_text"] = input_bert_vits2_style_text.value - config_data["bert_vits2"]["style_weight"] = round(float(input_bert_vits2_style_weight.value), 2) + config_data["bert_vits2"]["style_weight"] = input_bert_vits2_style_weight.value config_data["bert_vits2"]["auto_translate"] = switch_bert_vits2_auto_translate.value config_data["bert_vits2"]["auto_split"] = switch_bert_vits2_auto_split.value