<commit_before>const EventEmitter = require('events').EventEmitter;
const Prism = require('prism-media');
const StreamDispatcher = require('../dispatcher/StreamDispatcher');
const Collection = require('../../../util/Collection');
const OpusEncoders = require('../opus/OpusEngineList');

const ffmpegArguments = [
  '-analyzeduration', '0',
  '-loglevel', '0',
  '-f', 's16le',
  '-ar', '48000',
  '-ac', '2',
];

class AudioPlayer extends EventEmitter {
  constructor(voiceConnection) {
    super();
    this.voiceConnection = voiceConnection;
    this.prism = new Prism();
    this.opusEncoder = OpusEncoders.fetch();
    this.streams = new Collection();
    this.streamingData = {
      channels: 2,
      count: 0,
      sequence: 0,
      timestamp: 0,
      pausedTime: 0,
    };
  }

  get currentTranscoder() {
    return this.streams.last().transcoder;
  }

  destroyAllStreams(exceptLatest) {
    for (const stream of this.streams.keys()) {
      const data = this.streams.get(stream);
      const transcoder = data.transcoder;
      const dispatcher = data.dispatcher;
      if (exceptLatest && transcoder === this.currentTranscoder) continue;
      if (transcoder) transcoder.kill();
      if (dispatcher) dispatcher.destroy('end');
    }
  }

  playUnknownStream(stream, { seek = 0, volume = 1, passes = 1 } = {}) {
    const options = { seek, volume, passes };
    const transcoder = this.prism.transcode({
      type: 'ffmpeg',
      media: stream,
      ffmpegArguments,
    });
    this.streams.set(stream, { transcoder });<commit_msg>add back seek option<commit_after>const EventEmitter = require('events').EventEmitter;
const Prism = require('prism-media');
const StreamDispatcher = require('../dispatcher/StreamDispatcher');
const Collection = require('../../../util/Collection');
const OpusEncoders = require('../opus/OpusEngineList');

const ffmpegArguments = [
  '-analyzeduration', '0',
  '-loglevel', '0',
  '-f', 's16le',
  '-ar', '48000',
  '-ac', '2',
];

class AudioPlayer extends EventEmitter {
  constructor(voiceConnection) {
    super();
    this.voiceConnection = voiceConnection;
    this.prism = new Prism();
    this.opusEncoder = OpusEncoders.fetch();
    this.streams = new Collection();
    this.streamingData = {
      channels: 2,
      count: 0,
      sequence: 0,
      timestamp: 0,
      pausedTime: 0,
    };
  }

  get currentTranscoder() {
    return this.streams.last().transcoder;
  }

  destroyAllStreams(exceptLatest) {
    for (const stream of this.streams.keys()) {
      const data = this.streams.get(stream);
      const transcoder = data.transcoder;
      const dispatcher = data.dispatcher;
      if (exceptLatest && transcoder === this.currentTranscoder) continue;
      if (transcoder) transcoder.kill();
      if (dispatcher) dispatcher.destroy('end');
    }
  }

  playUnknownStream(stream, { seek = 0, volume = 1, passes = 1 } = {}) {
    const options = { seek, volume, passes };
    const transcoder = this.prism.transcode({
      type: 'ffmpeg',
      media: stream,
      ffmpegArguments: ffmpegArguments.concat(['-ss', String(seek)]),
    });
    this.streams.set(stream, { transcoder });
{'fraction_non_alphanumeric': 0.1520912547528517, 'fraction_numerical': 0.011406844106463879, 'mean_word_length': 3.2777777777777777, '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': '807863', 'n_tokens_mistral': 1013, 'n_tokens_neox': 980, 'n_words': 217}