路径跨平台兼容优化 - 修改相对路径,兼容Windows/Linux/Mac
This commit is contained in:
@@ -473,7 +473,7 @@ def generate_voiceover_volcengine_ws(
|
||||
) -> str:
|
||||
"""
|
||||
使用火山 WebSocket Binary Demo 生成 TTS 音频
|
||||
依赖目录:/Volumes/Tony/video-flow/volcengine_binary_demo/.venv/bin/python
|
||||
依赖目录:{PROJECT_ROOT}/volcengine_binary_demo/.venv/bin/python
|
||||
"""
|
||||
if not text or not text.strip():
|
||||
logger.warning("Empty text provided for TTS (ws)")
|
||||
@@ -481,8 +481,10 @@ def generate_voiceover_volcengine_ws(
|
||||
|
||||
voice_id = VOLC_TTS_VOICES.get(voice_type, voice_type)
|
||||
|
||||
venv_python = Path("/Volumes/Tony/video-flow/volcengine_binary_demo/.venv/bin/python")
|
||||
demo_script = Path("/Volumes/Tony/video-flow/volcengine_binary_demo/examples/volcengine/binary.py")
|
||||
# 跨平台路径:使用项目根目录相对路径
|
||||
volc_demo_dir = config.BASE_DIR / "volcengine_binary_demo"
|
||||
venv_python = volc_demo_dir / ".venv" / "bin" / "python"
|
||||
demo_script = volc_demo_dir / "examples" / "volcengine" / "binary.py"
|
||||
|
||||
if not venv_python.exists() or not demo_script.exists():
|
||||
logger.error("Volcengine WS demo or venv not found. Please install under volcengine_binary_demo/.venv")
|
||||
@@ -505,7 +507,7 @@ def generate_voiceover_volcengine_ws(
|
||||
try:
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
cwd="/Volumes/Tony/video-flow/volcengine_binary_demo",
|
||||
cwd=str(volc_demo_dir),
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=timeout,
|
||||
@@ -515,7 +517,7 @@ def generate_voiceover_volcengine_ws(
|
||||
return ""
|
||||
|
||||
# demo 保存在 cwd 下 voice_type.mp3
|
||||
demo_out = Path("/Volumes/Tony/video-flow/volcengine_binary_demo") / f"{voice_id}.mp3"
|
||||
demo_out = volc_demo_dir / f"{voice_id}.mp3"
|
||||
if not demo_out.exists():
|
||||
logger.error("Volc WS TTS output not found")
|
||||
return ""
|
||||
|
||||
Reference in New Issue
Block a user