mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-04-13 09:39:17 +00:00
24 lines
599 B
Python
24 lines
599 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,
|
||
|
"normalization_options": {
|
||
|
"normalize": True
|
||
|
}
|
||
|
}
|
||
|
)
|
||
|
|
||
|
# Save audio
|
||
|
with open("output.mp3", "wb") as f:
|
||
|
f.write(response.content)
|