XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet
公开
关注 0 Fork 0 Star 1
返回提交历史

XFEstudio/gpt4free

Add missing Audio model

eb05b878
hlohaus <983577+hlohaus@users.noreply.github.com>
提交于

代码差异

1 个文件 +9 -0
Modified g4f/providers/response.py +9 -0
@@ -1,6 +1,7 @@
1 1 from __future__ import annotations
2 2
3 3 import re
4 import base64
4 5 from typing import Union, Dict, List, Optional
5 6 from abc import abstractmethod
6 7 from urllib.parse import quote_plus, unquote_plus
@@ -228,6 +229,14 @@ class Sources(ResponseType):
228 229 for idx, link in enumerate(self.list)
229 230 ]))
230 231
232 class Audio(HiddenResponse):
233 def __init__(self, data: bytes) -> None:
234 self.data = data
235
236 def to_string(self) -> str:
237 data_base64 = base64.b64encode(self.data).decode()
238 return f"data:audio/mpeg;base64,{data_base64}"
239
231 240 class YouTube(ResponseType):
232 241 def __init__(self, ids: List[str]) -> None:
233 242 """Initialize with a list of YouTube IDs."""