Java:比较两个音频文件,看它们是否是相同的“音乐”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11988052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 07:10:52  来源:igfitidea点击:

Java: Comparing two audio files to see if they are the same "music"

javaaudio

提问by ThaSaleni

I'm working on a music streaming service and I've come across a problem: how do I compare two audio files to see if they represent the same song. The files might not have the same extension (e.g OGG, mp3, wma) but might still be the same song, and they might have a different bit rate and volume level.

我正在开发音乐流媒体服务,但遇到了一个问题:如何比较两个音频文件以查看它们是否代表同一首歌曲。这些文件可能没有相同的扩展名(例如 OGG、mp3、wma)但可能仍然是同一首歌曲,并且它们可能具有不同的比特率和音量级别。

采纳答案by Matt

Search for "audio fingerprinting". A possible solution might be this libraryor this paper.

搜索“音频指纹”。一个可能的解决方案可能是这个图书馆这篇论文

回答by Karim Varela

I'd check out Google's open source lib musicg API: http://code.google.com/p/musicg/

我会查看谷歌的开源库音乐 API:http: //code.google.com/p/musicg/

It's Java and gives similarity metrics for two audio files.

它是 Java 并给出了两个音频文件的相似性度量。

回答by Daniel Cukier

You can use the Open Source echoprint

您可以使用开源回显

Basically, you will generate a fingerprint of your local song and compare it with a database of songs if it is found.

基本上,您将生成本地歌曲的指纹并将其与歌曲数据库进行比较(如果找到)。

If you want to compare two of your songs, what you need to do is to create a local database with the first song and then try to match the second song in your own database. If it is found, means they are the same.

如果你想比较你的两首歌曲,你需要做的是用第一首歌曲创建一个本地数据库,然后尝试在你自己的数据库中匹配第二首歌曲。如果找到,则表示它们是相同的。

Note that the concept of "being the same song" is tricky. Actually what fingerprint does is compare many parts of the song, trying to match these many parts. This means that even if you have interferences in the audio (like people speaking, background noise, etc) you can be able to match a song, because most of the audio will be similar to the original.

请注意,“成为同一首歌”的概念很棘手。实际上指纹的作用是比较歌曲的许多部分,试图匹配这许多部分。这意味着即使您的音频受到干扰(例如人们说话、背景噪音等),您也可以匹配一首歌曲,因为大部分音频将与原始音频相似。

There is a paper explaining how echoprint works in details

有一篇论文详细解释了 echoprint 的工作原理

回答by Less

For something like this (being that I do a little of audio producing), you'll need some sort of algorithms that can perform spectrum analysis (probably using FFT - Fast Fourier Transformations).
Check this question here.

对于这样的事情(因为我做了一些音频制作),您将需要某种可以执行频谱分析的算法(可能使用 FFT - 快速傅立叶变换)。在这里
检查这个问题