小编Mic*_*l B的帖子

Python - chatbot AI有没有使用nltk?

我正在尝试聊天AI,我很好奇是否有人使用nltk,并且可以指出我如何使用它来生成基于信息nltk收集的响应,以及如何存储收集的nltk信息?我一直在研究这个,但是空洞的.

python artificial-intelligence nltk

1
推荐指数
1
解决办法
7957
查看次数

我需要建议我应该使用选择还是线程?

我正在构建一个实时广播流媒体,我想知道我应该如何处理多个连接。现在,根据我的经验,选择将阻止音频流式传输。它只播放 3 秒然后停止播放。我将举例说明我的意思。

import socket, select

headers = """
HTTP/1.0 200 OK\n
Content-Type: audio/mpeg\n
Connection: keep-alive\n
\n\n
"""
file="/path/to/file.mp3"
bufsize=4096 # actually have no idea what this should be but python-shout uses this amount
sock = socket.socket()
cons = list()
buf = 0
nbuf = 0

def runMe():
    cons.append(sock)
    file = open(file)
    nbuf = file.read(bufsize) # current buffer
    while True:
        buf = nbuf
        nbuf = file.read(bufsize)
        if len(buf) == 0:
           break
        rl, wl, xl = select.select(cons, [], [], 0.2)
        for …
Run Code Online (Sandbox Code Playgroud)

python multithreading http-live-streaming

1
推荐指数
1
解决办法
2419
查看次数