简体   繁体   English

为什么要使用udacity gui和scipy从wav文件中提取样本,并给出不同的值?

[英]Why extract sample from wav file using udacity gui and scipy give different values?

I have an audio wav file of 7seconds: full.wav. 我有一个7秒的音频wav文件:full.wav。

I extract a small sample of it. 我提取了一个小样本。 I select the timeframe using audacity and I label it. 我使用大胆性选择时间范围并标记时间。 I export the label (containing start and end time of the sample). 我导出标签(包含样本的开始和结束时间)。

1/ I export the sample using audacity menu and save it as sample_audacity.wav 1 /我使用audacity菜单导出样本并将其另存为sample_audacity.wav

2/ I load in a python script the full.wav using scipy.io.wavfile.read I save the sample full[start:end]. 2 /我使用scipy.io.wavfile.read在python脚本中加载了full.wav,我将示例保存为full [start:end]。 It gives me sample_python.wav 它给我sample_python.wav

When I listen to sample_audacity.wav and sample_python.wav I hear the same. 当我收听sample_audacity.wav和sample_python.wav时,我听到的声音相同。

But if I load both of them using scipy.io.wavfile.read I got very different values for the 2 files. 但是,如果我使用scipy.io.wavfile.read加载这两个文件,则两个文件的值将有很大不同。 the values of sample_python.wav are subset of the values of full.wav - which is normal. sample_python.wav的值是full.wav的值的子集-正常。

But the values of sample_audacity.wav are not. 但是sample_audacity.wav的值不是。

Does someone know why/how audacity is modifying the initial data (full.wav) when saving an extract of it? 有人知道保存原始数据提取时胆怯为何/如何修改初始数据(full.wav)吗?

And if possible how to get audacity to give me as sample that will have same values (subset) of the initial data? 并且,如果可能的话,如何让胆量给我作为具有相同初始数据值(子集)的样本?

As an example, the first 100 values of sample_audacity.wav 例如,sample_audacity.wav的前100个值

[128 122 124 123 134 138 143 142 139 135 144 149 155 156 148 144 143 144 151 152 159 152 160 150 157 151 155 153 155 156 154 151 145 139 128 132 124 131 130 129 123 115 104 100 94 94 88 85 78 74 65 59 52 48 43 45 46 45 40 30 19 10 6 7 14 15 12 0 -8 1 23 51 72 63 55 26 23 20 31 36 40 35 27 22 15 15 7 9 1 -2 -4 0 -3 -4 -18 -25 -25 -12 -1 -9]

Shape of sample_audacity.wav: (36296,) sample_audacity.wav的形状:(36296,)

the first 100 values of sample_python.wav sample_python.wav的前100个值

[128 127 124 122 125 132 139 143 142 138 137 142 150 155 155 149 144 142 145 150 154 156 156 155 155 154 153 153 154 155 156 154 151 145 138 131 128 127 129 131 129 123 114 105 99 95 93 89 84 79 73 66 59 52 47 44 45 46 45 39 31 19 10 5 8 13 16 11 0 -7 0 23 52 69 68 50 30 20 22 30 37 39 35 28 21 16 13 10 7 2 -3 -3 -1 -1 -6 -17 -26 -24 -12 -2]

Shape of sample_python.wav: (36297,) sample_python.wav的形状:(36297,)

Audacity 2.1.2 Ubuntu Audacity 2.1.2 Ubuntu

Preferences import/export: 首选项导入/导出: 在此处输入图片说明

Export settings: 导出设置: 在此处输入图片说明

Media info for both files: 两个文件的媒体信息: 在此处输入图片说明

Once the file is imported into audacity, it is converted to 32-bit format. 将文件导入到audacity后,它将转换为32位格式。 When you re-export the file back to 16-bits, audacity will dither the audio according to the preferences. 当您将文件重新导出回16位时,Audacity将根据首选项使音频抖动。 There are more details on this page: https://wiki.audacityteam.org/wiki/Dither 此页面上还有更多详细信息: https : //wiki.audacityteam.org/wiki/Dither

This export setting is not in an obvious location. 此导出设置不在明显的位置。 Go to Preferences/Quality and then Dither under the "High Quality Conversion" heading. 转到“偏好设置/质量”,然后转到“高质量转换”标题下的“抖动”。 If you set this to None you should get the same results as python. 如果将其设置为None,则应获得与python相同的结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM