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

fix stream mode, last chunk of audio file size #564

Merged
merged 5 commits into from
Jul 16, 2024
Merged

Conversation

Ox0400
Copy link
Contributor

@Ox0400 Ox0400 commented Jul 12, 2024

  1. Request buffer size.
  2. Remove padding zeros.

#521

## stream mode
[idx=1] 总耗时: 18.45 递增耗时:0.00 Received: len(message)=16000 Total: 16000
[idx=2] 总耗时: 19.46 递增耗时:1.01 Received: len(message)=16000 Total: 32000
[idx=3] 总耗时: 20.33 递增耗时:0.87 Received: len(message)=16000 Total: 48000
[idx=4] 总耗时: 21.05 递增耗时:0.72 Received: len(message)=16000 Total: 64000
[idx=5] 总耗时: 21.05 递增耗时:0.00 Received: len(message)=14848 Total: 78848

## no-stream mode
[idx=1] 总耗时: 4.23 递增耗时:0.00 Received: len(message)=78848 Total: 78848

@github-actions github-actions bot changed the base branch from main to dev July 12, 2024 07:39
@Ox0400 Ox0400 changed the title fix stream mode, last chunk of audio file size #https://github.com/2noise/ChatTTS/issues/521 fix stream mode, last chunk of audio file size #521 Jul 12, 2024
@Ox0400 Ox0400 changed the title fix stream mode, last chunk of audio file size #521 fix stream mode, last chunk of audio file size Jul 12, 2024
@fumiama
Copy link
Member

fumiama commented Jul 12, 2024

要注意从后往前删除连续的0,以避免真正的编码中确实有0的可能性(虽然小,但不是没有)。

@Ox0400
Copy link
Contributor Author

Ox0400 commented Jul 12, 2024

>>> import numpy as np
>>> 
>>> array = np.array([[1, 2, 3, 0, 0],
...                   [4, 5, 6, 0, 0],
...                   [0, 0, 0, 0, 0],
...                   [7, 0, 9, 0, 0],
...                   [0, 0, 0, 0, 0]])
>>> 
>>> # Identify rows with non-zero elements using np.any
>>> keep_rows = np.any(array != 0, axis=1)
>>> keep_cols = np.sum(array != 0, axis=0) > 0
>>> # Filter both rows and columns using slicing
>>> result = array[keep_rows, :][:, keep_cols]
>>> 
>>> 
>>> result
array([[1, 2, 3],
       [4, 5, 6],
       [7, 0, 9]])
>>> 



@fumiama
Copy link
Member

fumiama commented Jul 12, 2024

维数不能变啊,就算给个[]或者None也行。另外,请解决冲突(可以先用最新版代码覆盖,然后加以更改)

@Ox0400
Copy link
Contributor Author

Ox0400 commented Jul 12, 2024

维数不能变啊,就算给个[]或者None也行。另外,请解决冲突(可以先用最新版代码覆盖,然后加以更改)

我实际测试中是没有问题的, 所有的噪音都没了... 我是想 16k 的大小, 如果某个维度全是 0, 这个维度是不是本身就有问题

@fumiama
Copy link
Member

fumiama commented Jul 12, 2024

如果某个维度全是 0, 这个维度是不是本身就有问题

是有问题,但不能错位,要不其它的都对不上下标了,这就把问题扩大了。

@Ox0400
Copy link
Contributor Author

Ox0400 commented Jul 15, 2024

按照这个逻辑 ? 最后一行全 0 需要删么

>>> array = np.array(
... [[1, 2, 3, 0, 0],
... [4, 5, 6, 0, 0],
... [0, 0, 0, 0, 0],
... [7, 0, 9, 0, 0],
... [7, 0, 9, 2, 0],
... [0, 0, 0, 0, 0]]
... )

>>> result
array([[1, 2, 3, 0],
       [4, 5, 6, 0],
       [0, 0, 0, 0],
       [7, 0, 9, 0],
       [7, 0, 9, 2],
       [0, 0, 0, 0]])

@fumiama
Copy link
Member

fumiama commented Jul 15, 2024

最后一行全 0 需要删么

不用,就这样就行。👍

@fumiama fumiama linked an issue Jul 15, 2024 that may be closed by this pull request
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!

@fumiama fumiama merged commit e609093 into 2noise:dev Jul 16, 2024
5 checks passed
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.

流式输出的音频有噪音
2 participants