add dashscope tts

This commit is contained in:
Xin Wang
2026-02-26 03:02:48 +08:00
parent 6744646390
commit 562341a72c
9 changed files with 542 additions and 59 deletions

View File

@@ -61,6 +61,25 @@ agent:
""".strip()
def _dashscope_tts_yaml() -> str:
return _full_agent_yaml().replace(
""" tts:
provider: openai_compatible
api_key: test-tts-key
api_url: https://example-tts.invalid/v1/audio/speech
model: FunAudioLLM/CosyVoice2-0.5B
voice: anna
speed: 1.0
""",
""" tts:
provider: dashscope
api_key: test-dashscope-key
voice: Cherry
speed: 1.0
""",
)
def test_cli_profile_loads_agent_yaml(monkeypatch, tmp_path):
monkeypatch.chdir(tmp_path)
config_dir = tmp_path / "config" / "agents"
@@ -152,6 +171,28 @@ def test_missing_tts_api_url_fails(monkeypatch, tmp_path):
load_settings(argv=["--agent-config", str(file_path)])
def test_dashscope_tts_allows_default_url_and_model(monkeypatch, tmp_path):
monkeypatch.chdir(tmp_path)
file_path = tmp_path / "dashscope-tts.yaml"
_write_yaml(file_path, _dashscope_tts_yaml())
settings = load_settings(argv=["--agent-config", str(file_path)])
assert settings.tts_provider == "dashscope"
assert settings.tts_api_key == "test-dashscope-key"
assert settings.tts_api_url is None
assert settings.tts_model is None
def test_dashscope_tts_requires_api_key(monkeypatch, tmp_path):
monkeypatch.chdir(tmp_path)
file_path = tmp_path / "dashscope-tts-missing-key.yaml"
_write_yaml(file_path, _dashscope_tts_yaml().replace(" api_key: test-dashscope-key\n", ""))
with pytest.raises(ValueError, match="Missing required agent settings in YAML"):
load_settings(argv=["--agent-config", str(file_path)])
def test_missing_asr_api_url_fails(monkeypatch, tmp_path):
monkeypatch.chdir(tmp_path)
file_path = tmp_path / "missing-asr-url.yaml"