🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
add:openai text to speech
zhangleicc92d8fb4afd
diff --git a/metagpt/provider/openai_api.py b/metagpt/provider/openai_api.pyindex 3f3a4e1a7..3a9aca870 100644--- a/metagpt/provider/openai_api.py+++ b/metagpt/provider/openai_api.py@@ -235,3 +235,7 @@ class OpenAILLM(BaseLLM):async def amoderation(self, content: Union[str, list[str]]):"""Moderate content."""return await self.aclient.moderations.create(input=content)++ async def atext_to_speech(self, **kwargs):+ """text to speech"""+ return await self.aclient.audio.speech.create(**kwargs)diff --git a/tests/metagpt/provider/test_openai.py b/tests/metagpt/provider/test_openai.pyindex ca9e918da..cb0d0d636 100644--- a/tests/metagpt/provider/test_openai.py+++ b/tests/metagpt/provider/test_openai.py@@ -42,6 +42,18 @@ async def test_aask_code_message():assert len(rsp["code"]) > 0+async def test_text_to_speech():+ llm = LLM()+ resp = await llm.atext_to_speech(+ model="tts-1",+ voice="alloy",+ input="人生说起来长,但知道一个岁月回头看,许多事件仅是仓促的。一段一段拼凑一起,合成了人生。苦难当头时,当下不免觉得是折磨;回头看,也不够是一段短短的人生旅程。",+ )+ assert 200 == resp.response.status_code+++class TestOpenAI:def test_make_client_kwargs_without_proxy(self):instance = OpenAILLM(mock_llm_config)