音频识别和比较 [英] audio recognition and comparison

查看:69
本文介绍了音频识别和比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个小组项目.我们正在寻求开发一个程序,该程序可以接收音频并将其与保存的音频文件进行比较,并在输入和保存的文件匹配时输出音频消息.

I am working on a group project. We are looking to develop a program that can receive audio and compare it to a saved audio file and output a audio message if the input and saved files match.

我们想将音频文件与某种python方法进行比较,但是我们找不到任何方法可以做到这一点.我们正在寻找某种类型的库,以便能够从每个文件中获取数据并查看它们是否相似.

不知道如何开始.如果有人可以帮助我们入门或为我们指明正确的方向,我认为我们可以从那里接下去.

Can't figure out how to get started. If someone can help us get started or point us in the right direction, I think we can take it from there.

我们已经看了几十个教程,在网络上搜索,仍然需要一些主要帮助. 有人可以向我们解释如何开始吗?

We have watched a few dozen tutorials, searched the web and still need some major help. Could someone explain to us how to get started?

推荐答案

Python有很多方法可以做到这一点.我认为您可以比较文件而无需广泛的音频库.我可能是错的.否则,请查看struct模块以将wave文件转换为可读的整数.尝试一下以查看是否有效.

Python has a lot of ways to do this. I think you can just compare the files without an extensive audio library. I could be wrong. Otherwise, look into the struct module to convert your wave files into readable integers. Try this to see if it works.

import wave
w_one = wave.open('file_one', 'r')
w_two = wave.open('file_two', 'r')

if w_one.readframes() == w_two.readframes():
    print('exactly the same')
else:
    print('not a match')

音频消息输出是不常见的,将占用一个TTS库,因此只需坚持打印即可.您可以大声朗读结果.告诉我是否有效.目前,我在移动设备上,因此无法对其进行测试,但它应该可以工作.您还可以保存自己的发言权,然后使用以下命令在python中运行它:

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:

import os
os.system('prerecorded message.wav')

确保您的音频是wave文件. 希望我能帮上忙.在科学博览会上玩得开心!

Make sure your audio is wave files. I hope I was of help. Have fun at the science fair!

如果要使音频文件相似,则必须拍摄每一帧并设置它们可以分开的频率范围,然后从文件中的所有点开始进行比较.然后,您必须创建一个递归for循环,当它不在范围内时会中断,并从文件的下一个点开始.那将是一个项目的成功,祝您好运!您还可以为背景噪声创建降噪算法,这将是一些复杂的数学运算.如果你想看看他们是否是

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

完全匹配 ,请使用上面的代码.至于流式传输音频,实际上并没有消除背景噪音的方法,因此您可能需要调查一些模块……保存的音频文件和录制的音频文件少于一个.完全相同的1/44000 ^ s(s是音频的时间,以秒为单位).您可能只需要使用Alexa服务器

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

使用python滚动可能会很难,但是一旦您突破了理解的障碍,您就可以做一些很酷的事情.我最近刚为python的海龟制作了一个图形包装器,我将其编程为以3D方式显示正在飞行的火箭飞船!在您看来,这听起来像是希腊语,或者听起来不多,但看到您所做的工作如此出色,这真是太酷了.

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 thought
from scipy.io.wavfile import read as wavread
[samplerate, y] = wavread('Comparison.wav')
[samplerate, z] = wavread('Recording.wav')
for x in range(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.

这篇关于音频识别和比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆