小编TVa*_*rmy的帖子

用python检查音频并将其分为高,中,低音高可视化的好方法是什么?

因此,我打算尝试使用Arduino和Python制作一个灯管,通过串行通信来控制几个LED的亮度.计算机将使用麦克风或播放MP3来生成数据.

我不太确定如何处理音频处理.什么是python的一个很好的选择,可以采取播放音频文件或麦克风数据(我更喜欢麦克风),然后将其分成不同的频率范围,并将强度写入变量?如果我使用麦克风,是否需要担心泛音?

python audio

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

list [-1]在python程序中产生"list index out of range"错误

我正在尝试构建一个马尔可夫生成器,它为字符串链接任意长度作为编程练习,但我发现了一个我似乎无法修复的错误.当我运行markov函数时,我得到列表索引超出范围.

我觉得我忽略了一些明显的东西,但我不确定是什么.追溯说错误是在第41行,有words[-1] = nextWords[random.randint(0, len(nextWords)-1)].

完整代码如下,对不起,如果缩进被搞砸了.

#! /usr/bin/python

# To change this template, choose Tools | Templates
# and open the template in the editor.

import random

class Markov(object):
    def __init__(self, open_file):
        self.cache = {}
    self.open_file = open_file
    open_file.seek(0)
    self.wordlist = open_file.read().split()

def get_random_list(self, length):
    i = random.randint(0, len(self.wordlist) - (length - 1))
    result = self.wordlist[i:i + length]
    return result

def find_next_word(self, words):
    candidates = []
    for i in range(len(self.wordlist) - len(words)):
        if self.wordlist[i:i + len(words)] == words …
Run Code Online (Sandbox Code Playgroud)

python markov python-2.x

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

标签 统计

python ×2

audio ×1

markov ×1

python-2.x ×1