Hi, can I apply your library in realtime tempo detection?
So signal will be recorded in frames and send in model somthing like in Local tempo estimation...
Do you have any recommendation, frame length...and is this possible at all or does the complete audio file have to be loaded?
This is my code which does not work:
`from tempocnn.classifier import TempoClassifier
from tempocnn.feature import read_features
import pyaudio
import numpy as np
from librosa import util
for i in range(0, int(fs/chunk * seconds)):
data = stream.read(chunk)
data_pcm = util.buf_to_float(data, dtype=np.float32)
features = read_features(data_pcm, frames=256, hop_length=32)
estimate local tempi, this returns tempo classes, i.e., a distribution
local_tempo_classes = classifier.estimate(features)
# find argmax per frame and convert class index to BPM value
max_predictions = np.argmax(local_tempo_classes, axis=1)
local_tempi = classifier.to_bpm(max_predictions)
print(f"Estimated local tempo classes: {local_tempi}")
Hi, can I apply your library in realtime tempo detection? So signal will be recorded in frames and send in model somthing like in Local tempo estimation... Do you have any recommendation, frame length...and is this possible at all or does the complete audio file have to be loaded? This is my code which does not work: `from tempocnn.classifier import TempoClassifier from tempocnn.feature import read_features import pyaudio import numpy as np from librosa import util
model_name = 'cnn' classifier = TempoClassifier(model_name)
chunk = 2048 sample_format = pyaudio.paInt16 channels = 1 fs = 11025 # frames per channel seconds = 50 p=pyaudio.PyAudio() print("Recording ...") stream = p.open(format = sample_format, channels = channels, rate = fs, frames_per_buffer = chunk, input = True)
for i in range(0, int(fs/chunk * seconds)): data = stream.read(chunk) data_pcm = util.buf_to_float(data, dtype=np.float32) features = read_features(data_pcm, frames=256, hop_length=32)
estimate local tempi, this returns tempo classes, i.e., a distribution
stream.stop_stream() stream.close() p.terminate() print("... Ending Recording") `