Skip to content

fish.audio的付费API有个问题 #26

@ben0oil1

Description

@ben0oil1

我从云端tts服务器生成的wav音频文件,代码如下:

 with open(output_path, "wb") as f:
            for chunk in session.tts(TTSRequest(
                reference_id=self.voice_id, text= text.strip(), format="wav", sample_rate = 44100 ,
                )):
                f.write(chunk)  

生成的wav音频文件,用VLC可以播放,用pygame就不可以,相关关键代码:

pygame.mixer.music.load('1.wav')
pygame.mixer.music.play()

失败信息:Bad WAV file (no DATA chunk)

ffmpeg -y -i ./_tmp/1.wav -acodec pcm_s16le -ar 44100 -ac 1 ./_tmp/fixed.wav 我用ffmpeg强制补全文件信息之后就正常了。

我用python的wave库验证。修复前后的文件,nframes这个参数前面是0 ,后面nframes会发生变化。
原来:_wave_params(nchannels=1, sampwidth=2, framerate=44100, nframes=0, comptype='NONE', compname='not compressed')
修复后:_wave_params(nchannels=1, sampwidth=2, framerate=44100, nframes=45056, comptype='NONE', compname='not compressed')

deepseek: nframes=0表明文件头中缺少有效的音频帧数信息

骚操作啊!居然没有文件时长的信息,导致pygame无法加载。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions