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

Streaming input to streaming TTS #10

Open
santhosh-sp opened this issue Dec 7, 2023 · 8 comments
Open

Streaming input to streaming TTS #10

santhosh-sp opened this issue Dec 7, 2023 · 8 comments

Comments

@santhosh-sp
Copy link

Hello Team,

Is it possible to run TTS streaming with streaming input text with same file name?

Example:

def llm_write(prompt: str):

    for chunk in openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        message=[{"role": "user", "content": prompt}],
        stream=True
    ):
        if (text_chunk := chunk["choice"][0]["delta"].get("content")) is not None:
            yield text_chunk

text_stream = llm_write("Hello, what is LLM?")

audio = stream_ffplay(
    tts(
        args.text,
        speaker,
        args.language,
        args.server_url,
        args.stream_chunk_size
    ), 
    args.output_file,
    save=bool(args.output_file)
)

With minimum words to the TTS api.

Thanks,
Santhosh

@mercuryyy
Copy link

Is this possible?

@santhosh-sp
Copy link
Author

Yes, Its possible.

@mercuryyy
Copy link

Is it build into the [xtts-streaming-server] repo ? or it has to be tweaked?

I was getting ready to test it out this weekend before i install it.

@mercuryyy
Copy link

Any chance you can post some working examples? was able to get the docker working but i dont see any logic for providing the yield chunks as the text to the api

@nurgel
Copy link

nurgel commented Jan 2, 2024

is splitting at end of sentence (.?!) the best option here?

@Fusion9334
Copy link

def llm_write(prompt: str):
buffer = ""
for chunk in openai.ChatCompletion.create(
model="gpt-3.5-turbo",
message=[{"role": "user", "content": prompt}],
stream=True
):
if (text_chunk := chunk["choice"][0]["delta"].get("content")) is not None:
buffer += text_chunk
if should_send_to_tts(buffer): # Define this function to decide when to send
yield buffer
buffer = "" # Reset buffer after sending

text_stream = llm_write("Hello, what is LLM?")

for text in text_stream:
audio = stream_ffplay(
tts(
text,
speaker,
language,
server_url,
stream_chunk_size
),
output_file,
save=bool(output_file)
)

@AI-General
Copy link

I believe input needs to be at least a sentence, as speech relies heavily on the context provided by subsequent words.

@oscody
Copy link

oscody commented Jun 14, 2024

def llm_write(prompt: str): buffer = "" for chunk in openai.ChatCompletion.create( model="gpt-3.5-turbo", message=[{"role": "user", "content": prompt}], stream=True ): if (text_chunk := chunk["choice"][0]["delta"].get("content")) is not None: buffer += text_chunk if should_send_to_tts(buffer): # Define this function to decide when to send yield buffer buffer = "" # Reset buffer after sending

text_stream = llm_write("Hello, what is LLM?")

for text in text_stream: audio = stream_ffplay( tts( text, speaker, language, server_url, stream_chunk_size ), output_file, save=bool(output_file) )

does this work

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

No branches or pull requests

6 participants