feat: add ASR provider support for voice co-creation
This commit is contained in:
@@ -244,8 +244,9 @@ class TestProviderPolicy:
|
||||
policies = list_capability_policies()
|
||||
capabilities = {item["capability"] for item in policies}
|
||||
|
||||
assert capabilities == {"text", "image", "tts", "storybook"}
|
||||
assert capabilities == {"text", "image", "tts", "storybook", "asr"}
|
||||
assert DEFAULT_PROVIDERS["storybook"] == ["storybook_primary"]
|
||||
assert DEFAULT_PROVIDERS["asr"] == ["demo"]
|
||||
|
||||
def test_demo_provider_only_added_to_supported_capabilities(self):
|
||||
settings = SimpleNamespace(
|
||||
@@ -253,6 +254,7 @@ class TestProviderPolicy:
|
||||
image_providers=["cqtai"],
|
||||
tts_providers=["edge_tts"],
|
||||
storybook_providers=["storybook_primary"],
|
||||
asr_providers=["openai_asr"],
|
||||
enable_demo_providers=True,
|
||||
)
|
||||
|
||||
@@ -263,6 +265,7 @@ class TestProviderPolicy:
|
||||
"storybook_primary",
|
||||
]
|
||||
assert get_provider_names_from_settings("tts", settings) == ["edge_tts"]
|
||||
assert get_provider_names_from_settings("asr", settings) == ["demo", "openai_asr"]
|
||||
|
||||
def test_policy_defaults_when_settings_lists_are_empty(self):
|
||||
settings = SimpleNamespace(
|
||||
@@ -270,6 +273,7 @@ class TestProviderPolicy:
|
||||
image_providers=[],
|
||||
tts_providers=[],
|
||||
storybook_providers=[],
|
||||
asr_providers=[],
|
||||
enable_demo_providers=False,
|
||||
)
|
||||
|
||||
@@ -279,6 +283,22 @@ class TestProviderPolicy:
|
||||
"elevenlabs",
|
||||
"edge_tts",
|
||||
]
|
||||
assert get_provider_names_from_settings("asr", settings) == ["demo"]
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_asr_demo_provider_uses_transcript_hint(self):
|
||||
from app.services import provider_router
|
||||
|
||||
result = await provider_router.transcribe_audio(
|
||||
audio_bytes=b"fake-audio",
|
||||
file_name="turn.webm",
|
||||
mime_type="audio/webm",
|
||||
transcript_hint="我想听一个小熊找星星的故事",
|
||||
)
|
||||
|
||||
assert result.transcript_text == "我想听一个小熊找星星的故事"
|
||||
assert result.confidence == 1.0
|
||||
assert result.provider == "demo"
|
||||
|
||||
|
||||
class TestProviderConfigFromDB:
|
||||
|
||||
Reference in New Issue
Block a user