波形误差:#未指定频道

2024-10-02 12:22:52 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用wave模块编辑wav文件的长度。然而,我似乎哪儿也去不了,因为我一直得到同样的错误,即通道数没有指定。尽管如此,当我写一些东西来查看通道数量时,我仍然会得到这个错误,或者当我试图设置通道数量时,如下所示:

def editLength(wavFile):
   file = wave.open(wavFile, 'w')
   file.setnchannels(file.getnchannels())
   x = file.getnchannels()
   print (x)

Tags: 模块文件编辑数量def错误openwave
1条回答
网友
1楼 · 发布于 2024-10-02 12:22:52

来自https://docs.python.org/3.7/library/wave.html#wave.open

wave.open(file, mode=None)

If file is a string, open the file by that name, otherwise treat it as a file-like
object.

mode can be:
'rb'    Read only mode.
'wb'    Write only mode.

Note that it does not allow read/write WAV files.

试图从WAV文件读写时,file对象在第一个file.getnchannels()时没有指定通道数。在

^{pr2}$

如果要编辑文件,应首先从原始文件读取并写入临时文件。然后将临时文件复制到原始文件上。在

相关问题 更多 >

    热门问题