版本:audio2face-2023.2.0
audio2face 新增 audio player,选择stream audio player.
import subprocess import os # 注意:请替换为你的Audio2Face实际安装路径 A2F_SCRIPTS_DIR = r"D:\pro_2026\audio2face-2023.2.0\exts\omni.audio2face.player\omni\audio2face\player\scripts\streaming_server/" def stream_audio_to_a2f(wav_file_path): """ 向正在运行的Audio2Face Streaming Player发送音频文件 """ # 切换到流服务器脚本目录 os.chdir(A2F_SCRIPTS_DIR) # 构建命令:使用test_client.py发送音频 # 假设你的Streaming Player在USD场景中的路径是 /World/StreamingPlayer command = f"python test_client.py {wav_file_path} /World/audio2face/StreamingPlayer" # command = f"python test_client.py {wav_file_path} /omni.audio2face.player.Player" command = f"python test_client.py {wav_file_path} /World/audio2face/Player" command = f"python test_client.py {wav_file_path} /World/audio2face/PlayerStreaming" try: subprocess.run(command, shell=True, check=True) print(f"成功发送音频: {wav_file_path}") except subprocess.CalledProcessError as e: print(f"发送失败,命令执行错误: {e}") except FileNotFoundError: print("错误:未找到test_client.py脚本,请检查A2F_SCRIPTS_DIR路径。") # 使用示例 stream_audio_to_a2f(r"D:\data\audios\post_0.wav")