Skip to content

Commit

Permalink
Merge pull request #688 from Ikaros-521/owner
Browse files Browse the repository at this point in the history
新增 虚拟身体 数字人视频播放器
  • Loading branch information
Ikaros-521 authored Mar 6, 2024
2 parents b42962f + 02b751d commit 7e001c3
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

`Luna AI` 是一款结合了最先进技术的虚拟AI主播。它的核心是一系列高效的人工智能模型,包括 `ChatterBot、GPT、Claude、langchain、chatglm、text-generation-webui、讯飞星火、智谱AI、谷歌Bard、文心一言、通义星尘、通义千问、千帆大模型、Gemini、Kimi Chat、QAnything、koboldcpp`。这些模型既可以在本地运行,也可以通过云端服务提供支持。

`Luna AI` 的外观由 `Live2D、Vtube Studio、xuniren、UE5 结合 Audio2Face、EasyAIVtuber` 技术打造,为用户提供了一个生动、互动的虚拟形象。这使得 `Luna AI` 能够在各大直播平台,如 `Bilibili、抖音、快手、微信视频号、斗鱼、YouTube、Twitch 和 TikTok`,进行实时互动直播。当然,它也可以在本地环境中与您进行个性化对话。
`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` 实现声音的变化,以适应不同的场景和角色。

Expand Down
6 changes: 5 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"EasyAIVtuber": {
"api_ip_port": "http://127.0.0.1:7888"
},
"digital_human_video_player": {
"api_ip_port": "http://127.0.0.1:8091"
},
"play_audio": {
"enable": true,
"text_split_enable": true,
Expand Down Expand Up @@ -1331,7 +1334,8 @@
"live2d": true,
"xuniren": true,
"unity": true,
"EasyAIVtuber": true
"EasyAIVtuber": true,
"digital_human_video_player": true
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion config.json.bak
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"EasyAIVtuber": {
"api_ip_port": "http://127.0.0.1:7888"
},
"digital_human_video_player": {
"api_ip_port": "http://127.0.0.1:8091"
},
"play_audio": {
"enable": true,
"text_split_enable": true,
Expand Down Expand Up @@ -1331,7 +1334,8 @@
"live2d": true,
"xuniren": true,
"unity": true,
"EasyAIVtuber": true
"EasyAIVtuber": true,
"digital_human_video_player": true
}
}
}
Expand Down
33 changes: 33 additions & 0 deletions utils/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,37 @@ async def EasyAIVtuber_api(self, audio_path=""):
return False



# 调用digital_human_video_player的api
async def digital_human_video_player_api(self, audio_path=""):
try:
from urllib.parse import urljoin

url = urljoin(self.config.get('digital_human_video_player', 'api_ip_port'), "/show")

data = {
"audio_path": os.path.abspath(audio_path),
"insert_index": -1
}

async with aiohttp.ClientSession() as session:
async with session.post(url, json=data) as response:
# 检查响应状态
if response.status == 200:
# 使用await等待异步获取JSON响应
json_response = await response.json()
logging.info(f"digital_human_video_player发送成功,返回:{json_response['message']}")

return True
else:
logging.error(f"digital_human_video_player发送失败,状态码:{response.status}")
return False

except Exception as e:
logging.error(traceback.format_exc())
return False


# 音频合成(edge-tts / vits_fast)并播放
def audio_synthesis(self, message):
try:
Expand Down Expand Up @@ -964,6 +995,8 @@ async def only_play_audio(self):
await self.xuniren_api(voice_tmp_path)
elif self.config.get("visual_body") == "EasyAIVtuber":
await self.EasyAIVtuber_api(voice_tmp_path)
elif self.config.get("visual_body") == "digital_human_video_player":
await self.digital_human_video_player_api(voice_tmp_path)
else:
if self.config.get("play_audio", "player") in ["audio_player", "audio_player_v2"]:
if "insert_index" in data_json:
Expand Down
23 changes: 19 additions & 4 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,10 @@ def common_textarea_handle(content):

if config.get("webui", "show_card", "visual_body", "EasyAIVtuber"):
config_data["EasyAIVtuber"]["api_ip_port"] = input_EasyAIVtuber_api_ip_port.value


if config.get("webui", "show_card", "visual_body", "digital_human_video_player"):
config_data["digital_human_video_player"]["api_ip_port"] = input_digital_human_video_player_api_ip_port.value

"""
文案
"""
Expand Down Expand Up @@ -1662,6 +1665,7 @@ def common_textarea_handle(content):
config_data["webui"]["show_card"]["visual_body"]["xuniren"] = switch_webui_show_card_visual_body_xuniren.value
config_data["webui"]["show_card"]["visual_body"]["unity"] = switch_webui_show_card_visual_body_unity.value
config_data["webui"]["show_card"]["visual_body"]["EasyAIVtuber"] = switch_webui_show_card_visual_body_EasyAIVtuber.value
config_data["webui"]["show_card"]["visual_body"]["digital_human_video_player"] = switch_webui_show_card_visual_body_digital_human_video_player.value

config_data["webui"]["theme"]["choose"] = select_webui_theme_choose.value

Expand Down Expand Up @@ -1814,7 +1818,11 @@ def common_textarea_handle(content):
value=config.get("chat_type")
).style("width:200px;")

select_visual_body = ui.select(label='虚拟身体', options={'xuniren': 'xuniren', 'unity': 'unity', 'EasyAIVtuber': 'EasyAIVtuber', '其他': '其他'}, value=config.get("visual_body")).style("width:200px;")
select_visual_body = ui.select(
label='虚拟身体',
options={'xuniren': 'xuniren', 'unity': 'unity', 'EasyAIVtuber': 'EasyAIVtuber', 'digital_human_video_player': '数字人视频播放器', '其他': '其他'},
value=config.get("visual_body")
).style("width:200px;")

select_audio_synthesis_type = ui.select(
label='语音合成',
Expand Down Expand Up @@ -3258,7 +3266,13 @@ def clear_tts_common_audio_card(file_path):
ui.label("EasyAIVtuber")
with ui.row():
input_EasyAIVtuber_api_ip_port = ui.input(label='API地址', value=config.get("EasyAIVtuber", "api_ip_port"), placeholder='对接EasyAIVtuber应用监听的ip和端口')


if config.get("webui", "show_card", "visual_body", "digital_human_video_player"):
with ui.card().style(card_css):
ui.label("digital_human_video_player")
with ui.row():
input_digital_human_video_player_api_ip_port = ui.input(label='API地址', value=config.get("digital_human_video_player", "api_ip_port"), placeholder='对接 数字人视频播放器 监听的ip和端口')


with ui.tab_panel(copywriting_page).style(tab_panel_css):
with ui.row():
Expand Down Expand Up @@ -3787,7 +3801,8 @@ def update_echart_gift():
switch_webui_show_card_visual_body_xuniren = ui.switch('xuniren', value=config.get("webui", "show_card", "visual_body", "xuniren")).style(switch_internal_css)
switch_webui_show_card_visual_body_unity = ui.switch('unity', value=config.get("webui", "show_card", "visual_body", "unity")).style(switch_internal_css)
switch_webui_show_card_visual_body_EasyAIVtuber = ui.switch('EasyAIVtuber', value=config.get("webui", "show_card", "visual_body", "EasyAIVtuber")).style(switch_internal_css)

switch_webui_show_card_visual_body_digital_human_video_player = ui.switch('digital_human_video_player', value=config.get("webui", "show_card", "visual_body", "digital_human_video_player")).style(switch_internal_css)



with ui.card().style(card_css):
Expand Down

0 comments on commit 7e001c3

Please sign in to comment.