mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-04-13 09:39:17 +00:00
22 lines
No EOL
546 B
Python
22 lines
No EOL
546 B
Python
import requests
|
|
|
|
|
|
response = requests.get("http://localhost:8880/v1/audio/voices")
|
|
voices = response.json()["voices"]
|
|
|
|
# Generate audio
|
|
response = requests.post(
|
|
"http://localhost:8880/v1/audio/speech",
|
|
json={
|
|
"model": "kokoro",
|
|
"input": "http://localhost:8880/web/",
|
|
"voice": "af_heart",
|
|
"response_format": "mp3", # Supported: mp3, wav, opus, flac
|
|
"speed": 1.0,
|
|
"stream":False,
|
|
}
|
|
)
|
|
|
|
# Save audio
|
|
with open("output.mp3", "wb") as f:
|
|
f.write(response.content) |