From 8aff30a350df8eeb544807bea9b8ddd7b1cd7e39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Wed, 30 Aug 2023 15:36:52 +0800 Subject: [PATCH] refactor: replace aiofile with aiofiles --- metagpt/tools/azure_tts.py | 3 ++- requirements.txt | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/metagpt/tools/azure_tts.py b/metagpt/tools/azure_tts.py index 3100e2a3a..0dc16d516 100644 --- a/metagpt/tools/azure_tts.py +++ b/metagpt/tools/azure_tts.py @@ -11,6 +11,7 @@ from pathlib import Path from uuid import uuid4 import base64 import sys +import aiofiles from metagpt.config import CONFIG, Config @@ -97,7 +98,7 @@ async def oas3_azsure_tts(text, lang="", voice="", style="", role="", subscripti filename = Path(__file__).resolve().parent / (str(uuid4()).replace("-", "") + ".wav") try: await tts.synthesize_speech(lang=lang, voice=voice, text=xml_value, output_file=str(filename)) - async with async_open(filename, mode="rb") as reader: + async with aiofiles.open(filename, mode="rb") as reader: data = await reader.read() base64_string = base64.b64encode(data).decode('utf-8') filename.unlink() diff --git a/requirements.txt b/requirements.txt index 25a480a68..ca7fcbfda 100644 --- a/requirements.txt +++ b/requirements.txt @@ -40,5 +40,4 @@ libcst==1.0.1 qdrant-client==1.4.0 connexion[swagger-ui] aiohttp_jinja2 -azure-cognitiveservices-speech==1.31.0 -aiofile \ No newline at end of file +azure-cognitiveservices-speech==1.31.0 \ No newline at end of file