python音频识别_音频识别和比较
已關閉。這個問題需要更加集中。它當前不接受答案。
想改善這個問題嗎?更新問題,使其僅通過編輯此帖子來關注一個問題。
2年前關閉。
我正在做一個小組項目。我們正在尋求開發一種程序,該程序可以接收音頻并將其與保存的音頻文件進行比較,并在輸入和保存的文件匹配時輸出音頻消息。
我們想將音頻文件與某種python方法進行比較,但是我們還找不到任何方法可以做到這一點。我們正在尋找某種類型的庫,以便能夠從每個文件中獲取數據并查看它們是否相似。
無法弄清楚如何開始。如果有人可以幫助我們入門或為我們指明正確的方向,我認為我們可以從那里接下去。
我們已經看了幾十本教程,在網絡上搜索,仍然需要一些主要幫助。有人可以向我們解釋如何開始嗎?
解決方案
Python有很多方法可以做到這一點。我認為您可以比較文件而無需廣泛的音頻庫。我可能是錯的。否則,請查看struct模塊以將wave文件轉換為可讀的整數。試試這個看看是否可行。
importwavew_one=wave.open('file_one','r')w_two=wave.open('file_two','r')ifw_one.readframes()==w_two.readframes():print('exactly the same')else:print('not a match')
The audio message output is uneccassary and will take a TTS library, so just stick with print. You could just read aloud the results. Tell me if it worked. Right now I'm on mobile, so I can't test it, but it should work. You could also just save yourself saying something, then run it in python using:
importosos.system('prerecorded message.wav')
Make sure your audio is wave files.
I hope I was of help. Have fun at the science fair!
If you want it to be if the audio files are similar, you'll have to take each frame and set a range in frequencies that they can be apart, then compare starting at all points in the file. Then you'll have to make a recursive for loop that breaks when it's not in range and starts from the next point in the file. That would be one heck of a project, good luck! You may also create a noise reducing algorithm for background noise, which would be some complicated math. If you want to see if they're
an exact match, use the above code. As for streaming the audio, there won't really be a way to get rid of the background noise, so you might want to look into some modules for that... also a saved audio file and a recorded audio file have less then a 1/44000^s (s is time in seconds of the audio) chance of being exactly the same. You may have to just use the Alexa server
It may be hard to get rolling with python, but once you break past the barrier of understanding, you can do some pretty cool things. I just recently made a graphics wrapper for python's turtle, which I programmed to display a flying rocket ship in 3D! That may either sound like Greek to you, or not sound like much, but it's pretty cool to see something you made work so well.
#Comparing them may be easier than I thoughtfromscipy.io.wavfileimportreadaswavread[samplerate,y]=wavread('Comparison.wav')[samplerate,z]=wavread('Recording.wav')forxinrange(0,samplerate,4):#Slight compression for the program to run faster.y1,y2=[y[x][0],y[x][1]]#y1,y2 are numbers for your in Comparison.wav. Use these to compare to file 2.z1,z2=[z[x][0],z[x][1]]#z1,z2 are numbers for you to compare.#Install scipy by holding down the window's Button & R. Then type in#pip install scipy#You may have to press enter a few times to get it to work, but overall, be patient. You should be able to figure out how to compare the files from here.
總結
以上是生活随笔為你收集整理的python音频识别_音频识别和比较的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 项目宝提供的服务器,开源WebSocke
- 下一篇: 红河学院计算机科学与技术,2016年红河