如何将mfcc矢量与注释中的标签结合起来传递给神经网络(How to combine mfcc vector with labels from annotation to pass to a neural network)
使用librosa,我为我的音频文件创建了mfcc,如下所示:
import librosa y, sr = librosa.load('myfile.wav') print y print sr mfcc=librosa.feature.mfcc(y=y, sr=sr)
我还有一个文本文件,其中包含与音频对应的手动注释[start,stop,tag],如下所示:
0.0 2.0声音1
2.0 4.0 sound2
4.0 6.0沉默
6.0 8.0 sound1问题:如何将生成的librosa生成的mfcc与文本文件中的注释结合起来。
最终目标是,我想结合对应于标签的mfcc,并传递
它到神经网络。
因此,神经网络将mfcc和相应的标签作为训练数据。如果它是一维的,我可以有N列N值,最后一列Y带有Class标签。 但我很困惑如何继续,因为mfcc的形状类似于(16,X)或(20,Y)。 所以我不知道如何将两者结合起来。
我的样本mfcc在这里: https : //gist.github.com/manbharae/0a53f8dfef6055feef1d8912044e1418
请帮忙谢谢。
更新:目标是训练神经网络,以便在将来遇到它时识别出新的声音。
我用Google搜索,发现mfcc非常适合演讲。 但是我的音频有语音,但我想识别非语音。 是否有其他推荐的音频功能用于通用音频分类/识别任务?
Using librosa, I created mfcc for my audio file as follows:
import librosa y, sr = librosa.load('myfile.wav') print y print sr mfcc=librosa.feature.mfcc(y=y, sr=sr)
I also have a text file that contains manual annotations[start, stop, tag] corresponding to the audio as follows:
0.0 2.0 sound1
2.0 4.0 sound2
4.0 6.0 silence
6.0 8.0 sound1QUESTION: How to do I combine the generated mfcc's that was generated by librosa, with the annotations from text file.
Final goal is, I want to combine mfcc corresponding to the label, and pass
it to a neural network.
So a neural network will have the mfcc and corresponding label as training data.If it was one dimensional , I could have N columns with N values and the final Column Y with a Class label. But i'm confused how to proceed, as the mfcc has the shape of something like (16, X) or (20, Y). So I don't know how to combine the two.
My sample mfcc's are here : https://gist.github.com/manbharae/0a53f8dfef6055feef1d8912044e1418
Please help thank you.
Update : Objective is to train a neural network so that it can identify a new sound when it encounters it in the future.
I googled and found that mfcc are very good for speech. However my audio has speech but I want to indentify non speech. Are there any other recommended audio features for a general purpose audio classification/recognition task?
原文:https://stackoverflow.com/questions/48388641
最满意答案
您更新数组值而不是
TableModel
值。 使用jTable.getModel().setValueAt()
传递inputRow,inputColoumn和它们的适当值。 您的模型必须是可编辑的。 如果您使用DefaultTableModel
则默认情况下它是可编辑的。You update array value not
TableModel
value. UsejTable.getModel().setValueAt()
passing inputRow, inputColoumn and appropriate value for them. Your model must be editable. If you useDefaultTableModel
it's editable by default.
相关问答
更多-
尝试规范化字符串以符合BigDecimal要求: private static BigDecimal parse(String str) { String normalized = str.replaceAll("\\s", "").replace(',', '.'); return new BigDecimal(normalized); } 上面的代码从输入字符串中删除所有空白字符(在BigDecimal构造函数中不允许)。 更重要的是 - 如果需要,它会将逗号替换为小数点。 Try t ...
-
@trashgod @mKorbel 感谢帮助人员,我通过在done()函数中将信息添加到表中来解决了这个问题。 代码如下 SwingWorker
worker = new SwingWorker< Void, Void>() { String[] billItems = null; @Override public Void doInBackground() { String SQL = "SELECT ... -
我建议你使用表格模型,只要数据改变你改变模型。 只需构建JTable实例一次,而不是每当需要更改数据时。 I suggest you use a table model, whenever the data changes you change the model. Build the JTable instance only once, not whenever you need to change the data.
-
Java Swing JTable列值和标题全宽,怎么可能?(Java Swing JTable column value and header full width, how is it possible?)[2024-01-13]
第一个答案 为此,您应该访问表的列,如下所示: TableColumn column = null; column = table.getColumnModel().getColumn(/*here the index of your column*/); column.sizeWidthToFit(); 如果标题为空或者什么都不做,请小心 一些来源以防万一https://docs.oracle.com/javase/tutorial/uiswing/components/table.html#width ... -
GustlyWind的评论是了解如何使用JTable的最佳地点。 数据的关键是获取模型中的项目。 您可以使用DefaultTableModel ,这需要将表结果放入2D数组或Vector中。 或者,您可以实现自己的模型,该模型使用应用程序中的其他自定义对象或不同的基础数据结构。 无论哪种方式,当您遍历查询的ResultSet ,您将不得不提取相关数据并将其粘贴到某种Collection 。 GustlyWind's comment is the best place to look on how to us ...
-
data = new DefaultTableModel(vectorData, columNames); table = new JTable(data); 您正在创建一个新的TableModel和一个新的JTable。 问题是你永远不会将新表添加到GUI。 您不能只更改对“table”变量的引用,并希望将表添加到GUI中。 因此解决方案是不创建新的JTable。 相反,您只需重置现有JTable的TableModel: data = new DefaultTableModel(vectorData, ...
-
JTable,Java(JTable, Java)[2023-06-12]
是的,但这经过编辑 模型不会跟踪值之前/之后。 如果您需要此信息,则需要自己完成。 或者,您可以使用Table Cell Listener为您执行此操作。 Yes, but this getting after edited The model does not track before/after values. If you want this information you need to do it yourself. Or, you can use the Table Cell Listener ... -
用Java中的计算结果的值替换JTable的值(Replace The Value Of JTable With The Value Of Calculation Result in Java)[2022-09-05]
您更新数组值而不是TableModel值。 使用jTable.getModel().setValueAt()传递inputRow,inputColoumn和它们的适当值。 您的模型必须是可编辑的。 如果您使用DefaultTableModel则默认情况下它是可编辑的。 You update array value not TableModel value. Use jTable.getModel().setValueAt() passing inputRow, inputColoumn and approp ... -
在JFrame中显示JTable(Displaying JTable in JFrame)[2023-04-14]
看到JTable教程,一切都在那里描述 我看不出有理由使用AbstractTableModel ,不知道为什么烦扰JTable包含实际数量的行和列(最多DefaultTableModel和DefaultTableModel ),而是从DefaultTableModel开始 或使用此AbstractTableModel更改DefaultTableModel 可以从一开始 import java.awt.*; import java.awt.event.ActionEvent; import java.awt. ... -
JTable高度计算(JTable height calculation)[2023-07-08]
您可以替换自己的Scrollable实现来获得各种效果。 特别是,覆盖getPreferredScrollableViewportSize()并返回行高的合适倍数。 设N是您希望滚动条出现的行数。 JTable table = new JTable(tableModel) { @Override public Dimension getPreferredScrollableViewportSize() { return new Dimension(SOME_WIDTH, N ...