diff --git a/Test.py b/Test.py new file mode 100644 index 0000000..0944861 --- /dev/null +++ b/Test.py @@ -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) \ No newline at end of file diff --git a/api/src/services/audio.py b/api/src/services/audio.py index 53c0ed4..8bc99bb 100644 --- a/api/src/services/audio.py +++ b/api/src/services/audio.py @@ -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)}") diff --git a/output.mp3 b/output.mp3 new file mode 100644 index 0000000..b6d7635 Binary files /dev/null and b/output.mp3 differ