@@ -148,11 +148,14 @@ async def convert_to_file_path(self) -> str:
148148 """
149149 url = self .url or self .file
150150 if not url :
151- raise Exception ( f"not a valid file: { url } " )
151+ raise ValueError ( "No valid file or URL provided " )
152152 if url .startswith ("file:///" ):
153153 return url [8 :]
154154 if url .startswith ("http" ):
155- file_path = await download_image_by_url (url )
155+ file_path = os .path .join (
156+ get_astrbot_temp_path (), f"recordseg_{ uuid .uuid4 ()} .amr"
157+ )
158+ await download_file (url , file_path )
156159 return os .path .abspath (file_path )
157160 if url .startswith ("base64://" ):
158161 bs64_data = url .removeprefix ("base64://" )
@@ -176,11 +179,14 @@ async def convert_to_base64(self) -> str:
176179 """
177180 url = self .url or self .file
178181 if not url :
179- raise Exception ( f"not a valid file: { url } " )
182+ raise ValueError ( "No valid file or URL provided " )
180183 if url .startswith ("file:///" ):
181184 bs64_data = file_to_base64 (url [8 :])
182185 elif url .startswith ("http" ):
183- file_path = await download_image_by_url (url )
186+ file_path = os .path .join (
187+ get_astrbot_temp_path (), f"recordseg_{ uuid .uuid4 ()} .amr"
188+ )
189+ await download_file (url , file_path )
184190 bs64_data = file_to_base64 (file_path )
185191 elif url .startswith ("base64://" ):
186192 bs64_data = url
0 commit comments