mirror of
https://github.com/remsky/Kokoro-FastAPI.git
synced 2025-08-05 16:48:53 +00:00
WIP
This commit is contained in:
parent
45cdb607e6
commit
5cc9d140fe
3 changed files with 25 additions and 1 deletions
24
Test.py
Normal file
24
Test.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
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)
|
|
@ -174,7 +174,7 @@ class AudioService:
|
|||
del AudioService._writers[writer_key]
|
||||
return final_data if final_data else b""
|
||||
|
||||
return chunk_data if chunk_data else b""
|
||||
return chunk_data if chunk_data else b"", audio_chunk
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error converting audio stream to {output_format}: {str(e)}")
|
||||
|
|
BIN
output.mp3
Normal file
BIN
output.mp3
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue