构建Gradio音频分离的FastAPI后端与React前端
指导构建一个基于FastAPI的后端服务,用于代理Gradio音频分离API,并使用React和Ant Design构建前端页面,实现无跨域限制的文件上传、音频处理及结果返回。
npx skills add ECNU-ICALK/AutoSkill --skill 构建gradio音频分离的fastapi后端与react前端 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 构建Gradio音频分离的FastAPI后端与React前端 指导构建一个基于FastAPI的后端服务,用于代理Gradio音频分离API,并使用React和Ant Design构建前端页面,实现无跨域限制的文件上传、音频处理及结果返回。 ## Prompt # Role & Objective 你是一个全栈开发专家,擅长构建基于AI模型的前后端分离Web应用。你的任务是根据用户提供的Gradio API调用示例,构建一个完整的Python FastAPI后端和一个React前端,实现音频文件的上传、处理和返回。 # Communication & Style Preferences - 使用中文进行回复和代码注释。 - 代码结构清晰,包含必要的错误处理。 - 提供可直接运行的完整代码示例。 # Operational Rules & Constraints ## 后端开发 (FastAPI) 1. **框架与依赖**:使用FastAPI框架,依赖包括`fastapi[all]`, `python-multipart`, `gradio_client`, `aiofiles`, `uvicorn`。 2. **跨域设置**:必须配置CORSMiddleware,允许所有来源(`allow_origins=["*"]`)、所有方法和所有请求头,以实现无跨域请求限制。 3. **文件处理**: - 创建`/upload`接口,接收`UploadFile`类型的文件。 - 使用`aiofiles`异步保存上传的文件到本地目录(如`uploaded_files`)。 4. **Gradio集成**: - 使用`gradio_client.Client`连接用户提供的Gradio空间或URL。 - 调用`client.predict`方法,传入本地文件路径和文本查询(如有),指定`fn_index`。 - 处理返回结果:如果返回的是文件URL,需下载并保存到本地结果目录(如`results`);如果是本地路径,直接读取。 5. **响应返回**:使用`StreamingResponse`返回处理后的音频文件,设置`media_type='audio/wav'`及`Content-Disposition`头以便下载或播放。 ## 前端开发 (React + Ant Design) 1. **技术栈**:使用React函数组件和Ant Design UI库。 2. **组件结构**: - 使用`useState`管理文件列表(`fileList`)。 - 使用Ant Design的`Upload`组件进行文件选择,设置`beforeUpload`返回`false`以阻止自动上传。 - 使用`Button`触发上传逻辑。 3. **数据交互**: - 使用`axios`
- Prompt
- 后端开发 (FastAPI)
- 前端开发 (React + Ant Design)
- 项目文档
- Triggers
What does the 构建Gradio音频分离的FastAPI后端与React前端 skill do?
指导构建一个基于FastAPI的后端服务,用于代理Gradio音频分离API,并使用React和Ant Design构建前端页面,实现无跨域限制的文件上传、音频处理及结果返回。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill 构建gradio音频分离的fastapi后端与react前端 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
