<commit_before>package wav

import (
	"fmt"
	"io"
	"time"

	"github.com/mattetti/audio"
	"github.com/mattetti/audio/riff"
)

// Decoder handles the decoding of wav files.
type Decoder struct {
	r      io.Reader
	parser *riff.Parser
	info   *Info
}

// New creates a decoder for the passed wav reader.
// Note that the reader doesn't get rewinded as the container is processed.
func NewDecoder(r io.Reader, c chan *audio.Chunk) *Decoder {
	return &Decoder{
		r:      r,
		parser: riff.New(r),
	}
}

// Decode reads from a Read Seeker and converts the input to a PCM
// clip output.
func Decode(r io.ReadSeeker) (audio.Clip, error) {
	d := &Decoder{r: r, parser: riff.New(r)}
	nfo, err := d.Info()
	if err != nil {
		return nil, err
	}
	clip := &Clip{
		r:          r,
		byteSize:   int(nfo.Duration.Seconds()) * int(time.Second) * int(nfo.AvgBytesPerSec),
		channels:   int(nfo.NumChannels),
		bitDepth:   int(nfo.NumChannels),
		sampleRate: int64(nfo.SampleRate),
	}

	return clip, nil
}

// Parse reads the content of the file, populates the decoder fields
// and pass the chunks to the provided channel.
// Note that the channel consumer needs to call Done() on the chunk
// to release the wait group and deain the chunk if needed.
func (d *Decoder) Parse(ch chan *riff.Chunk) error {
	d.parser.Chan = ch<commit_msg>riff/wav: temporary fix for the decoder<commit_after>package wav

import (
	"fmt"
	"io"
	"time"

	"github.com/mattetti/audio"
	"github.com/mattetti/audio/riff"
)

// Decoder handles the decoding of wav files.
type Decoder struct {
	r      io.Reader
	parser *riff.Parser
	info   *Info
}

// New creates a decoder for the passed wav reader.
// Note that the reader doesn't get rewinded as the container is processed.
func NewDecoder(r io.Reader, c chan *audio.Chunk) *Decoder {
	return &Decoder{
		r:      r,
		parser: riff.New(r),
	}
}

// Decode reads from a Read Seeker and converts the input to a PCM
// clip output.
func Decode(r io.ReadSeeker) (*Clip, error) {
	d := &Decoder{r: r, parser: riff.New(r)}
	nfo, err := d.Info()
	if err != nil {
		return nil, err
	}
	clip := &Clip{
		r:          r,
		byteSize:   int(nfo.Duration.Seconds()) * int(time.Second) * int(nfo.AvgBytesPerSec),
		channels:   int(nfo.NumChannels),
		bitDepth:   int(nfo.NumChannels),
		sampleRate: int64(nfo.SampleRate),
	}

	return clip, nil
}

// Parse reads the content of the file, populates the decoder fields
// and pass the chunks to the provided channel.
// Note that the channel consumer needs to call Done() on the chunk
// to release the wait group and deain the chunk if needed.
func (d *Decoder) Parse(ch chan *riff.Chunk) error {
	d.parser.Chan = ch
{'fraction_non_alphanumeric': 0.11817839668799397, 'fraction_numerical': 0.0015054572826496049, 'mean_word_length': 3.3009708737864076, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1958276', 'n_tokens_mistral': 978, 'n_tokens_neox': 932, 'n_words': 324}