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

support stream mode #360

Merged
merged 6 commits into from
Jun 19, 2024
Merged

support stream mode #360

merged 6 commits into from
Jun 19, 2024

Conversation

Ox0400
Copy link
Contributor

@Ox0400 Ox0400 commented Jun 19, 2024

usage

stream = True
wavs_gen = chat.infer('text here', stream=stream)

if stream:
     wavs = [np.array([[]])]
     for gen in wavs_gen:
         print('new chunk gen', gen)
         wavs[0] = np.hstack([wavs[0], np.array(gen[0])])
 else:
     print('check result', wavs_gen)
     wavs = wavs_gen

torchaudio.save("output1.wav", torch.from_numpy(wavs[0]), 24000)

Copy link
Member

@fumiama fumiama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

  • You can pull the latest code and resolve conflict.
  • You can add this stream version to examples/webui and examples/cmd

@fumiama fumiama added enhancement New feature or request algorithm Algorithm improvements & issues labels Jun 19, 2024
@fumiama fumiama merged commit f0babd0 into 2noise:main Jun 19, 2024
@Ox0400
Copy link
Contributor Author

Ox0400 commented Jun 19, 2024

@fumiama Thanks for you fixed my abnormal code. I'm trying add the tests to examples/cmd

@fumiama
Copy link
Member

fumiama commented Jun 19, 2024

You're welcome. You can change the webui and cmd directly to the stream mode in order to support long-sentence infer.

@Ox0400
Copy link
Contributor Author

Ox0400 commented Jun 19, 2024

You're welcome. You can change the webui and cmd directly to the stream mode in order to support long-sentence infer.

Okay, For cli mode, PR: #366

web mode is some complexity, just the first chunk need WAV header bytes. PCM mode will be better.

@jackbapa
Copy link

stream模式下有异常噪声。

@fumiama
Copy link
Member

fumiama commented Jul 10, 2024

stream模式下有异常噪声。

怀疑是gradio处理问题

@Ox0400
Copy link
Contributor Author

Ox0400 commented Jul 10, 2024

stream模式下有异常噪声。

怀疑是gradio处理问题

stream 模式下用 PCM, 或者去掉 WAV 包头.

fumiama added a commit that referenced this pull request Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
algorithm Algorithm improvements & issues enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants