<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  7 09:19:37 2014

@author: thomas
"""

from __future__ import division

import pygst
pygst.require("0.10")
import gobject
import gst
import numpy
import scipy.signal.waveforms
import os.path

#import timeside


class NumpySrc:
    def __init__(self, array, samplerate):
        self.appsrc = gst.element_factory_make("appsrc")
        self.pos = 0
        self.samplerate = samplerate
        if array.ndim == 1:
            array.resize((array.shape[0], 1))
        self.length, self.channels = array.shape
        self.array = array.astype("float32")
        self.per_sample = gst.SECOND // samplerate
        self.fac = self.channels * array.dtype.itemsize
        #self.appsrc.set_property("size", (self.length * self.channels *
        #                                  array.dtype.itemsize))
        self.appsrc.set_property("format", gst.FORMAT_TIME)
        capstr = """audio/x-raw-float,
                    width=%d,
                    depth=%d,
                    rate=%d,
                    channels=%d,
                    endianness=(int)1234,
                    signed=true""" % (32,#self.array.dtype.itemsize*8,
                                      32,#self.array.dtype.itemsize*8,
                                      self.samplerate,
                                      self.channels)
        print array.dtype.itemsize*8
        self.appsrc.set_property("caps", gst.caps_from_string(capstr))
        self.appsrc.set_property("stream-type", 0)  # Seekable
        self.appsrc.set_property('block', True)

        self.appsrc.connect("need-data", self.need_data)<commit_msg>Suppress printing of depth in  tools/data_samples<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Tue Oct  7 09:19:37 2014

@author: thomas
"""

from __future__ import division

import pygst
pygst.require("0.10")
import gobject
import gst
import numpy
import scipy.signal.waveforms
import os.path

#import timeside


class NumpySrc:
    def __init__(self, array, samplerate):
        self.appsrc = gst.element_factory_make("appsrc")
        self.pos = 0
        self.samplerate = samplerate
        if array.ndim == 1:
            array.resize((array.shape[0], 1))
        self.length, self.channels = array.shape
        self.array = array.astype("float32")
        self.per_sample = gst.SECOND // samplerate
        self.fac = self.channels * array.dtype.itemsize
        #self.appsrc.set_property("size", (self.length * self.channels *
        #                                  array.dtype.itemsize))
        self.appsrc.set_property("format", gst.FORMAT_TIME)
        capstr = """audio/x-raw-float,
                    width=%d,
                    depth=%d,
                    rate=%d,
                    channels=%d,
                    endianness=(int)1234,
                    signed=true""" % (self.array.dtype.itemsize*8,
                                      self.array.dtype.itemsize*8,
                                      self.samplerate,
                                      self.channels)
        self.appsrc.set_property("caps", gst.caps_from_string(capstr))
        self.appsrc.set_property("stream-type", 0)  # Seekable
        self.appsrc.set_property('block', True)

        self.appsrc.connect("need-data", self.need_data)
{'fraction_non_alphanumeric': 0.11789222983030664, 'fraction_numerical': 0.01816016671628461, 'mean_word_length': 1.7906976744186047, '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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4098358', 'n_tokens_mistral': 1054, 'n_tokens_neox': 998, 'n_words': 180}