mirror of
https://github.com/xtekky/gpt4free.git
synced 2026-01-06 09:13:04 -08:00
feat: add EdgeTTS audio provider and global image→media refactor
- **Docs**
- `docs/file.md`: update upload instructions to use inline `bucket` content parts instead of `tool_calls/bucket_tool`.
- `docs/media.md`: add asynchronous audio transcription example, detailed explanation, and notes.
- **New audio provider**
- Add `g4f/Provider/audio/EdgeTTS.py` implementing Edge Text‑to‑Speech (`EdgeTTS`).
- Create `g4f/Provider/audio/__init__.py` for provider export.
- Register provider in `g4f/Provider/__init__.py`.
- **Refactor image → media**
- Introduce `generated_media/` directory and `get_media_dir()` helper in `g4f/image/copy_images.py`; add `ensure_media_dir()`; keep back‑compat with legacy `generated_images/`.
- Replace `images_dir` references with `get_media_dir()` across:
- `g4f/api/__init__.py`
- `g4f/client/stubs.py`
- `g4f/gui/server/api.py`
- `g4f/gui/server/backend_api.py`
- `g4f/image/copy_images.py`
- Rename CLI/API config field/flag from `image_provider` to `media_provider` (`g4f/cli.py`, `g4f/api/__init__.py`, `g4f/client/__init__.py`).
- Extend `g4f/image/__init__.py`
- add `MEDIA_TYPE_MAP`, `get_extension()`
- revise `is_allowed_extension()`, `to_input_audio()` to support wider media types.
- **Provider adjustments**
- `g4f/Provider/ARTA.py`: swap `raise_error()` parameter order.
- `g4f/Provider/Cloudflare.py`: drop unused `MissingRequirementsError` import; move `get_args_from_nodriver()` inside try; handle `FileNotFoundError`.
- **Core enhancements**
- `g4f/providers/any_provider.py`: use `default_model` instead of literal `"default"`; broaden model/provider matching; update model list cleanup.
- `g4f/models.py`: safeguard provider count logic when model name is falsy.
- `g4f/providers/base_provider.py`: catch `json.JSONDecodeError` when reading auth cache, delete corrupted file.
- `g4f/providers/response.py`: allow `AudioResponse` to accept extra kwargs.
- **Misc**
- Remove obsolete `g4f/image.py`.
- `g4f/Provider/Cloudflare.py`, `g4f/client/types.py`: minor whitespace and import tidy‑ups.
This commit is contained in:
parent
0a070bdf10
commit
e83282fc4b
23 changed files with 253 additions and 387 deletions
|
|
@ -8,7 +8,7 @@ from flask import send_from_directory
|
|||
from inspect import signature
|
||||
|
||||
from ...errors import VersionNotFoundError, MissingAuthError
|
||||
from ...image.copy_images import copy_media, ensure_images_dir, images_dir
|
||||
from ...image.copy_images import copy_media, ensure_media_dir, get_media_dir
|
||||
from ...tools.run_tools import iter_run_tools
|
||||
from ... import Provider
|
||||
from ...providers.base_provider import ProviderModelMixin
|
||||
|
|
@ -96,8 +96,8 @@ class Api:
|
|||
}
|
||||
|
||||
def serve_images(self, name):
|
||||
ensure_images_dir()
|
||||
return send_from_directory(os.path.abspath(images_dir), name)
|
||||
ensure_media_dir()
|
||||
return send_from_directory(os.path.abspath(get_media_dir()), name)
|
||||
|
||||
def _prepare_conversation_kwargs(self, json_data: dict):
|
||||
kwargs = {**json_data}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue