我有一個python腳本來使用start,end time來分割wav文件。我想在arduino中執行這個。我可以直接運行arduino嗎?或者如果沒有,你能建議我想怎麼做?在arduino上運行python腳本
import wave
import pygame
import time
import sys
def slice(infile, outfilename, start_ms, end_ms):
width = infile.getsampwidth() #Returns sample width in bytes
rate = infile.getframerate() #Returns sampling frequency
fpms = rate/1000 # frames per ms
length = (end_ms - start_ms) * fpms
start_index = start_ms * fpms
out = wave.open(outfilename, "w")
out.setparams((infile.getnchannels(), width, rate, length, infile.getcomptype(), infile.getcompname()))
infile.rewind() #Rewind the file pointer to the beginning of the audio stream
anchor = infile.tell() #Return current file pointer position
infile.setpos(anchor + start_index) #Set the file pointer to the specified position
out.writeframes(infile.readframes(length)) #Write audio frames and make sure nframes is correct
if __name__ == "__main__":
slice(wave.open("song1.wav", "r"), "out.wav", int(sys.argv[1]), int(sys.argv[2]))
pygame.mixer.init()
pygame.mixer.music.load("out.wav")
pygame.mixer.music.play()
while pygame.mixer.music.get_busy() == True:
continue
我認爲你所要做的遠遠超出了Arduino的能力。樹莓派可以做到這一點。 –
和「否」,arduino無法執行python文件。因此你需要一個python解釋器。 –
我可以使用C++嗎?爲此我需要C++庫。我可以將C++庫導入到arduino中嗎? –