Watching generation lists during a program run

The Story: During Nina Zakharenko's PyCon talk on Memory Management in Python, she explains the way the generational garbage collection works in Python noting that: Python maintains a list of every object created as a program is run. Actually, it makes 3: generation 0 generation 1 generation 2 The question: To gain more understanding in Memory Management in Python and for the p

在程序运行期间观看生成列表

故事: 在Nina Zakharenko的PyCon关于Python内存管理的谈话中,她解释了代码垃圾收集在Python中的工作方式,指出: Python维护一个程序运行时创建的每个对象的列表。 实际上,它使3: generation 0 generation 1 generation 2 问题是: 为了更好地理解Python中的内存管理和调试内存泄漏的目的,我如何观察/观察程序运行期间在所有3代列表中添加和删除了哪些对象? 我已经浏览了gc模块,但还没有找到获取当前生

Speech or no speech detection in Python

I am writing a program that recognizes speech. What it does is it records audio from the microphone and converts it to text using Sphinx. My problem is I want to start recording audio only when something is spoken by the user. I experimented by reading the audio levels from the microphone and recording only when the level is above a particular value. But it ain't that effective. The pro

Python中的语音或无语音检测

我正在写一个能识别语音的程序。 它所做的是记录来自麦克风的音频并使用Sphinx将其转换为文本。 我的问题是我只想在用户说出某些内容时才开始录制音频。 我通过从麦克风读取音频电平并仅在电平高于特定值时进行记录来进行试验。 但它不是那么有效。 程序每当检测到任何响亮的声音时就开始录制。 这是我使用的代码 import audioop import pyaudio as pa import wav class speech(): def __init__(self): # so

AMQP 1.0 Library for Python

I'm looking for a AMQP 1.0 compliant Python library. I've gone through several libraries but they all seem to support only AMQP 0.9.1. amqp - https://pypi.python.org/pypi/amqp/1.4.7 pika - https://github.com/pika/pika amqplib - https://code.google.com/p/py-amqplib/ Puka (https://github.com/majek/puka) doesn't seem to mention the specific AMQP version it supports, but it only

适用于Python的AMQP 1.0库

我正在寻找一个兼容AMQP 1.0的Python库。 我经历了几个库,但他们似乎都只支持AMQP 0.9.1。 amqp - https://pypi.python.org/pypi/amqp/1.4.7 pika - https://github.com/pika/pika amqplib - https://code.google.com/p/py-amqplib/ Puka(https://github.com/majek/puka)似乎没有提到它支持的特定AMQP版本,但它只是说它是一个RabbitMQ客户端。 Apache Qpid项目为客户提供许多符合AMQP 1.0标准的编程语言。

Synchronous AMQP publish

I know there is a number of libraries, implementing AMQP support in python. What I need, though, is a library, that will allow me to do AMQP publish in a synchronous style, because it will be used from a WSGI app, so the usual asynchronous callback-driven style of interaction with the queue broker will be a bit out of place there. Other parts of the system use pika for AMQP support, but it is

同步AMQP发布

我知道有很多库,在python中实现AMQP支持。 我需要的是一个库,它允许我以同步方式执行AMQP发布,因为它将从WSGI应用程序中使用,所以通常的异步回调驱动的与队列代理交互的风格将是有点不合适。 系统的其他部分使用pika进行AMQP支持,但它是异步的,即使存在某种“阻塞”连接,我宁愿不使用它。 当然,如果一切都失败了,每个WSGI进程都可以维护一个Pika事件循环。 另一个问题是,我在当前的Pika稳定版中发现了一些令人讨厌

passing transformation matrix into shader

I am having trouble passing projection and modelview matrices into the GLSL shader from my PyOpenGL code. My understanding is that OpenGL matrices are column major, but when I pass in projection and modelview matrices as shown, I don't see anything. I tried the transpose of the matrices, and it worked for the modelview matrix, but the projection matrix doesn't work either way. Here is

将变换矩阵传递给着色器

我无法通过PyOpenGL代码将投影和模型视图矩阵传递到GLSL着色器中。 我的理解是,OpenGL矩阵是列主要的,但是当我如图所示传递投影和模型视图矩阵时,我什么都看不到。 我尝试了矩阵的转置,它对模型视图矩阵起作用,但投影矩阵无论如何都不起作用。 代码如下: import OpenGL from OpenGL.GL import * from OpenGL.GL.shaders import * from OpenGL.GLU import * from OpenGL.GLUT import * from OpenGL.GLUT.freeglut impor

Comparing logical values to NaN in pandas/numpy

I want to do an element-wise OR operation on two pandas Series of boolean values. np.nan s are also included. I have tried three approaches and realized that the expression " np.nan or False " can be evaluted to True , False , and np.nan depending on the approach. These are my example Series: series_1 = pd.Series([True, False, np.nan]) series_2 = pd.Series([False, False, False])

将逻辑值与pandas / numpy中的NaN进行比较

我想对两个熊猫系列的布尔值做一个元素或操作。 np.nan s也包括在内。 我尝试了三种方法,并意识到可以根据方法将表达式“ np.nan或False ” np.nan为True , False和np.nan 。 这些是我的例子系列: series_1 = pd.Series([True, False, np.nan]) series_2 = pd.Series([False, False, False]) 方法#1 使用| 熊猫运营商: In [5]: series_1 | series_2 Out[5]: 0 True 1 False 2 False dtype: bool 方法

How to avoid brackets in SQL around Django custom database function call?

A short intoduction to the problem... PostgreSQL has very neat array fields (int array, string array) and functions for them like UNNEST and ANY . These fields are supported by Django (I am using djorm_pgarray for that), but functions are not natively supported. One could use .extra() , but Django 1.8 introduced a new concept of database functions. Let me provide a most primitive example

如何避免在Django自定义数据库函数调用周围的SQL中括号?

对问题进行简短的介绍... PostgreSQL具有非常整齐的数组字段(int数组,字符串数组)和像UNNEST和ANY一样的函数。 Django支持这些字段(我使用的是djorm_pgarray ),但函数不是本机支持的。 可以使用.extra() ,但Django 1.8引入了数据库函数的新概念。 让我提供一个最原始的例子,说明我基本上用这些做的事情。 Dealer有一个它支持的品牌清单。 Vehicle有制造并与经销商联系。 但它发生的Vehicle的制作不符合Dealer

Time audio processing in Python

I'm trying to write a program for analyzing chunks of audio recorded by my computer. I would like to be able to seperate the audio into chunks that are about 5 seconds long (220500 samples or so) and if there isn't 5 seconds worth of samples available, just take whatever is left (eg if recording for 32 seconds, I'd like to seperate the stream into 6 segments that are 5 seconds long a

Python中的时间音频处理

我正在编写一个程序来分析我的电脑记录的音频块。 我希望能够将音频分成大约5秒钟的大块(220500个样本左右),如果没有5秒钟的样本可用,只需要留下任何东西(例如,如果录制32秒,我想将流分成6段,长5秒,最后一段2秒)。 我正在使用Pyaudio录制音频 stream=p.open(format=pyaudio.paInt16,channels=1,rate=RATE,input=True, input_device_index=1, output_device_index=6,frames_per_buffer=1500, stream_callba

Redirecting audio output from one function to another function in python

Suppose I have two functions drawn from two different APIs, function A and B. By default, function A outputs audio data to a wav file. By default, function B takes audio input from a wav file and process it. Is it possible to stream the data from function A to B? If so, how do I do this? I work on lubuntu if that is relevant. This is function A I'm thinking about from the PJSUA pyth

在python中将音频输出从一个函数重定向到另一个函数

假设我有两个函数来自两个不同的API,函数A和B. 默认情况下,功能A将音频数据输出到wav文件。 默认情况下,功能B从wav文件获取音频输入并进行处理。 是否有可能将数据从功能A流式传输到B? 如果是这样,我该怎么做? 如果这是相关的,我在研究lubuntu。 这是我从PJSUA python API中想到的函数: create_recorder(self,filename)创建WAV文件记录器。 关键字参数文件名 - WAV文件名 返回:WAV记录器ID 这是

How to edit raw PCM audio data without an audio library?

I'm interested in precisely extracting portions of a PCM WAV file, down to the sample level. Most audio modules seem to rely on platform-specific audio libraries. I want to make this cross platform and speed is not an issue, are there any native python audio modules that can do this? If not, I'll have to interpret the PCM binary. While I'm sure I can dig up the PCM specs fairly e

如何在没有音频库的情况下编辑原始PCM音频数据?

我感兴趣的是精确提取PCM WAV文件的一部分,直到样本级别。 大多数音频模块似乎依赖于平台特定的音频库。 我想让这个跨平台和速度不是问题,有没有任何原生python音频模块可以做到这一点? 如果没有,我将不得不解释PCM二进制文件。 虽然我确信我可以很容易地挖掘PCM规格,并且原始格式很容易走路,但我从来没有在Python中处理过二进制数据。 有没有解释如何做到这一点的好资源? 具体与音频有关将只是结冰。 我读了这