sherpa-onnx icon indicating copy to clipboard operation
sherpa-onnx copied to clipboard

Add situation when SubChunk1Size == 18

Open eugeneYz opened this issue 1 year ago • 3 comments
trafficstars

NAudio音频库录制的16k音频的 SubChunk1Size = 18 ,导致Line49报错
Console.WriteLine($"Invalid SubChunk1Size: {SubChunk1Size}. Expect 16"); 此行改为 if (SubChunk1Size != 16 && SubChunk1Size != 18)

然后将 SkipMetaData方法改为如下,即可取出音频数据:

    private void SkipMetaData(BinaryReader reader)
    {
        var bs = reader.BaseStream;

        Int32 subChunk2ID = _header.SubChunk2ID;
        Int32 subChunk1Size = _header.SubChunk1Size;
        Int32 subChunk2Size = _header.SubChunk2Size;
        if (subChunk1Size == 16)
        {
            while (bs.Position != bs.Length && subChunk2ID != 0x61746164)
            {
                bs.Seek(subChunk2Size, SeekOrigin.Current);
                subChunk2ID = reader.ReadInt32();
                subChunk2Size = reader.ReadInt32();
            }
            _header.SubChunk2ID = subChunk2ID;
            _header.SubChunk2Size = subChunk2Size;
        }
        else
        {

                subChunk2Size = (int)(bs.Length - bs.Position);
            
        }

        _header.SubChunk2ID = subChunk2ID;
        _header.SubChunk2Size = subChunk2Size;
    }

eugeneYz avatar Mar 14 '24 09:03 eugeneYz

Looks like you have uploaded encrypted files. Could you fix that?

csukuangfj avatar Mar 14 '24 09:03 csukuangfj

@eugeneYz

csukuangfj avatar Mar 19 '24 10:03 csukuangfj

Looks like you have uploaded encrypted files. Could you fix that? Sorry about that,It seems that these codes can be only added manually.

eugeneYz avatar Mar 20 '24 02:03 eugeneYz