Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST API for infer #764

Closed
wants to merge 1 commit into from
Closed

POST API for infer #764

wants to merge 1 commit into from

Conversation

ban1989ban
Copy link

Created API for TTS:

Usage:
#(A) Get JSON-Encoded Base64
curl -X POST "http://localhost:8000/tts/"
-H "Content-Type: application/json"
-d '{"text": "Hello, how can I help you?", "response_type": "json"}'

#(B) Save audio to file
curl -X POST "http://localhost:8000/tts/"
-H "Content-Type: application/json"
-d '{"text": "Hello, how can I help you?", "response_type": "file"}'
-o output.wav

#(C) Stream Audio in real time
curl -X POST "http://localhost:8000/tts/"
-H "Content-Type: application/json"
-d '{"text": "Hello, how can I help you?", "response_type": "stream"}'
--output - | aplay

@SWivid
Copy link
Owner

SWivid commented Feb 3, 2025

Hi @banank1989 ,

Maybe you could help provide some infos about the streaming performance compared with https://github.com/SWivid/F5-TTS/blob/main/src/f5_tts/socket_server.py

TIA~

@ban1989ban
Copy link
Author

@SWivid Havent run benchmark on both but I guess both serves different purpose. Code i wrote expose API while socket file do not. Also socket sends the audio in one go once it is generated while API code does actual streaming (stream when the chunk is ready)

@SWivid
Copy link
Owner

SWivid commented Feb 4, 2025

Also socket sends the audio in one go once it is generated while API code does actual streaming (stream when the chunk is ready)

From code, seems the same? Both wait for infer_batch_process to finish, just that here you return directly while socket version provide a play_steps_in_s for extra control.
And from what you want in #763 , streaming performance is the key point we should consider first and yes was the original purpose of people propose socket script.

@SWivid SWivid closed this Feb 5, 2025
@goranskular
Copy link

goranskular commented Feb 8, 2025

But this is for a different purpose. It would be nice to have this API in it. @ban1989ban thanks for the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants