Download app.py from buchi-stdesign/sbv2_gradio_wrapper_api2: direct link, hf CLI and curl.
- Browser
- Download file 765 Bytes
-
https://huggingface.co/spaces/buchi-stdesign/sbv2_gradio_wrapper_api2/resolve/main/app.py
- Command line
-
hf download hf://spaces/buchi-stdesign/sbv2_gradio_wrapper_api2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/buchi-stdesign/sbv2_gradio_wrapper_api2/resolve/main/app.py
765 Bytes
| from fastapi import FastAPI, Query | |
| import requests | |
| app = FastAPI() | |
| GRADIO_API = "https://buchi-stdesign-sbv2-editor-demo.hf.space/run/predict" | |
| GRADIO_FILE_BASE = "https://buchi-stdesign-sbv2-editor-demo.hf.space/file" | |
| def get_voice(text: str = Query(...), style: str = "小春音アミ"): | |
| payload = { | |
| "data": [text, style, 1.0, 1.0, 0.5] | |
| } | |
| headers = {"Content-Type": "application/json"} | |
| res = requests.post(GRADIO_API, json=payload, headers=headers) | |
| if res.status_code != 200: | |
| return {"error": "Gradio backend error", "detail": res.text} | |
| result = res.json() | |
| wav_path = result["data"][0] # tmp/audio.wav | |
| wav_url = f"{GRADIO_FILE_BASE}/{wav_path}" | |
| return {"audio_url": wav_url} |