我在使用 pyaudio 时遇到一些问题。
我正在使用 python 3.6.7、pyaudio 版本 0.2.11 开发 ubuntu 18.04,并具有以下依赖项:
基本上我正在运行这个:
python
import pyaudio
import wave
CHUNK = 2048*50
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
RECORD_SECONDS = 3
WAVE_OUTPUT_FILENAME = "test.wav"
p = pyaudio.PyAudio()
info = p.get_host_api_info_by_index(0)
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
if (p.get_device_info_by_host_api_device_index(0,i).get('maxInputChannels')) > 0:
print("Input Device id ", i, " - ", p.get_device_info_by_host_api_device_index(0, i).get('name'))
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input=True,
frames_per_buffer=CHUNK, input_device_index=0)
print("* recording")
frames = []
for …Run Code Online (Sandbox Code Playgroud) 我试图做一个警告消息框,几秒钟后自动消失。我已经完成了这个代码:
def warning(self):
messagebox = QtGui.QMessageBox(self)
messagebox.setWindowTitle("wait")
messagebox.setText("wait (closing automatically in {0} secondes.)".format(3))
messagebox.setStandardButtons(messagebox.NoButton)
self.timer2 = QtCore.QTimer()
self.time_to_wait = 3
def close_messagebox(e):
e.accept()
self.timer2.stop()
self.time_to_wait = 3
def decompte():
messagebox.setText("wait (closing automatically in {0} secondes.)".format(self.time_to_wait))
if self.time_to_wait <= 0:
messagebox.closeEvent = close_messagebox
messagebox.close()
self.time_to_wait -= 1
self.connect(self.timer2,QtCore.SIGNAL("timeout()"),decompte)
self.timer2.start(1000)
messagebox.exec_()
Run Code Online (Sandbox Code Playgroud)
对于自动关闭部分,它实际上工作得很好。我的问题是,当有人尝试在几秒钟之前手动关闭它时,通过单击窗口的 x 按钮,消息框永远不会关闭。“等待时间”变为负数,例如消息框显示“在 -4 秒内自动关闭”,并且永远不会关闭。
知道如何避免这种情况吗?问候
我正在尝试了解 MongoDB 中的更改流。
我试图仅显示更新文档的某些字段。
所以我做了:
option={ 'full_document':'updateLookup' }
collection.watch([{"$match" : { "operationType" : "update" }}] , **option)
Run Code Online (Sandbox Code Playgroud)
这是工作。
现在我只想显示一些字段。
我试过:
collection.watch([{"$match" : { "operationType" : "update" }},{"$project":{"_id":1}}] , **option)
Run Code Online (Sandbox Code Playgroud)
或者
collection.watch([{"$match" : { "operationType" : "update" }}],option).aggregate({"$project":{"_id":1}})
Run Code Online (Sandbox Code Playgroud)
但它们都不起作用。
如何仅显示选定的字段?
我想从我的Web API访问多个文件夹位置以显示图像。我无法更改文件夹位置(取决于我无权修改任何内容的设备)。
对于我做过的其中一个文件夹:
string FolderToListen = Configuration["xxx:yyy"];
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(FolderToListen),
});
Run Code Online (Sandbox Code Playgroud)
现在我想做的是:
string FolderToListen2= Configuration["xxx2:yyy2"];
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(FolderToListen),
FileProvider = new PhysicalFileProvider(FolderToListen2),
});
Run Code Online (Sandbox Code Playgroud)
但这不起作用。有什么办法可以将多个文件夹传递给UseStaticFiles?
在 Linux 上,我将 CMake 配置为在bin文件夹中安装输出。
然后我可以在终端中调用可执行文件,无论当前目录是什么。
我做了:
Install(TARGETS ... DESTINATION bin)
Run Code Online (Sandbox Code Playgroud)
在 Windows 上,它不起作用。它告诉我:
“whatever”不被识别为内部或外部命令、可操作程序或批处理文件。
Windows 的等效目标是什么?
asp.net-core ×1
c# ×1
changestream ×1
cmake ×1
directory ×1
mongodb ×1
pyaudio ×1
pyqt ×1
pyqt4 ×1
pyqt5 ×1
python ×1
python-3.x ×1
qmessagebox ×1
watch ×1
windows ×1