我正在尝试从python中的TIMIT数据库中读取一个wav文件,但是我收到一个错误:
当我使用wave时:
wave.Error: file does not start with RIFF id
Run Code Online (Sandbox Code Playgroud)
当我使用scipy时:
ValueError: File format b'NIST'... not understood.
Run Code Online (Sandbox Code Playgroud)
当我使用librosa时,程序卡住了.我尝试使用sox将其转换为wav:
cmd = "sox " + wav_file + " -t wav " + new_wav
subprocess.call(cmd, shell=True)
Run Code Online (Sandbox Code Playgroud)
它没有帮助.我看到一个引用scikits.audiolab包的旧答案,但看起来它不再受支持了.
如何读取这些文件以获取数据的数据?
谢谢
Mathematica语法还是新手.当我做:
DSolve[{
D[u[x, t], {x, 2}] == (1/(v*v))*D[u[x, t], {t, 2}],
u[0, t] == 0,
u[l, 0] == 0
}, u, {x, t}]
Run Code Online (Sandbox Code Playgroud)
它只是返回我输入的内容
DSolve[{(u^(2,0))[x,t]==(u^(0,2))[x,t]/v^2,u[0,t]==0,u[l,0]==0},u,{x,t}]
Run Code Online (Sandbox Code Playgroud)
但是,当我删除边界条件时,我得到了
{{u->Function[{x,t},C[1][t-(Sqrt[v^2] x)/v^2]+C[2][t+(Sqrt[v^2] x)/v^2]]}}
Run Code Online (Sandbox Code Playgroud)
用C [1]和C [2]表示边界条件的函数.
任何人都知道为什么会这样吗?
我一直试图在Android上合并两个WAVE文件很长一段时间,但实际上似乎无法让它正常工作.
一切看起来都很好,文件被读取,并写入输出文件,该文件在稍后阶段也是可读的,并且具有我期望看到的文件大小.
应用程序完成合并后立即出现问题.此消息将显示在日志中:updateListener中发生错误,记录被中止,这是一个消息来自extAudioRecorder并且在OnRecordPositionUpdateListener到达catch子句时出现(Exception具有以下detailMessage:写入失败:EBADF(错误的文件编号)).这似乎没有破坏任何东西,所以我不太担心这一点.
当我尝试创建一个MediaPlayer并调用setDataSource(String path)MediaPlayer实例时,会出现真正的问题.每当我使用合并文件执行此操作时,日志中将显示以下错误消息:无法创建媒体播放器(IOException抛出的内容包含以下detailMessage:setDataSourceFD failed:status = 0x80000000).请注意,第一次文件将完全正常播放(该第一个文件不是由该combineWaveFiles()方法创建的).该错误消息似乎表示音频文件的格式不正确和/或MediaPlayer无法读取.
我的问题是,如果有人看到下面的代码有任何实际问题(我知道它在很多方面是次优的,但我更喜欢让它先工作,然后担心性能).
public static String MergeRecordings(String cumulativeFile, String recordFile, int sampleRate, int bpp, int bufferSize, int channels) {
if (cumulativeFile == null) {
return recordFile;
} else if (recordFile == null) {
return cumulativeFile;
}
String outputFile = FileUtils.getFilePath(null, MDSettings.shared().getMainActivity());
FileUtils.combineWaveFiles(cumulativeFile, recordFile, outputFile, sampleRate, bpp, bufferSize, channels);
//FileUtils.removeFile(cumulativeFile);
//FileUtils.removeFile(recordFile);
return outputFile;
}
//creates …Run Code Online (Sandbox Code Playgroud) 我必须从Python中的立体声波形文件中的一个通道读取数据.为此我用scipy.io试了一下:
import scipy.io.wavfile as wf
import numpy
def read(path):
data = wf.read(path)
for frame in data[1]:
data = numpy.append(data, frame[0])
return data
Run Code Online (Sandbox Code Playgroud)
但是这段代码非常慢,特别是如果我必须使用更长的文件.那么有人知道更快的方法吗?我通过使用wave.readframes()来考虑标准波形模块,但帧是如何存储的?
我正在wav使用 module.Python 读取音频文件wave。该库中的函数readframe()以十六进制字符串形式返回帧。我想删除\x这个字符串,但translate()函数无法按我想要的方式工作:
>>> input = wave.open(r"G:\Workspace\wav\1.wav",'r')
>>> input.readframes (1)
'\xff\x1f\x00\xe8'
>>> '\xff\x1f\x00\xe8'.translate(None,'\\x')
'\xff\x1f\x00\xe8'
>>> '\xff\x1f\x00\xe8'.translate(None,'\x')
ValueError: invalid \x escape
>>> '\xff\x1f\x00\xe8'.translate(None,r'\x')
'\xff\x1f\x00\xe8'
>>>
Run Code Online (Sandbox Code Playgroud)
无论如何,我想将结果值除以 2,然后\x再次相加并生成包含这些新值的新wav文件。有人有更好的主意吗?
怎么了?
我正在使用MaterializeCSS(http://materializecss.com/)建立我的网站
我想知道如何手动触发某些控件的波动效果,例如:
“触发某些按钮的波动/波纹效果。”
MaterializeCSS团队认为他们使用的是“ Waves.js” JavaScript库的端口(http://fian.my.id/Waves/),但是当我尝试使用这些命令时,浏览器控制台中会出现错误。
有人可以在这里指出我吗?
代码用作示例:
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="css/materialize.css" media="screen,projection"/>
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!--Import jQuery before materialize.js-->
<script type="text/javascript" src="jquery/jquery.min.js"></script>
<script type="text/javascript" src="js/materialize.min.js"></script>
<title>My website title</title>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
Waves.ripple('#but_1');
});
</script>
<a id="but_1" class="waves-effect waves-light btn">button</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
根据MaterializeCSS TEAM ...
“ Waves是我们包含在Materialize中的外部库,可让我们创建Material Design中概述的墨水效果”
...并根据Waves文档....
Waves.ripple(elements,options)以编程方式在HTML元素中创建波纹效果。
我想阅读左右声道。
import wave
origAudio = wave.open("6980.wav","r")
frameRate = origAudio.getframerate()
nChannels = origAudio.getnchannels()
sampWidth = origAudio.getsampwidth()
nbframe=origAudio.getnframes()
da = np.fromstring(origAudio.readframes(48000), dtype=np.int16)
origAudio.getparams()
Run Code Online (Sandbox Code Playgroud)
参数
(2, 3, 48000, 2883584, 'NONE', 'not compressed')
Run Code Online (Sandbox Code Playgroud)
现在我想用 24 位数据中的波形文件分隔左右声道
我正在寻找一种快速,最好是标准的库机制来确定wav文件的位深度,例如“ 16位”或“ 24位”。
我正在使用对Sox的子过程调用来获取过多的音频元数据,但是子过程调用非常慢,并且我目前只能从Sox可靠地获得的唯一信息是位深度。
内置的wave模块不具有“ getbitdepth()”之类的功能,并且与24位的wav文件也不兼容-我可以使用wave模块使用“ tryexcept”来访问文件元数据(如果可以,请手动记录它是16位的),然后调用sox(在sox将执行分析以准确记录其位深度的位置)上。我担心的是,这种方法感觉像是猜测。如果读取8位文件怎么办?如果不是,我将手动分配16位。
SciPy.io.wavefile也与24位音频不兼容,因此会产生类似的问题。
本教程非常有趣,甚至包括一些非常低级的脚本示例(至少对于Python来说是低级),这些示例可从wav文件头中提取信息-不幸的是,这些脚本不适用于16位音频。
有什么方法可以简单地(无需调用sox)确定我要检查的wav文件的位深度?
我正在使用的wave标头解析器脚本如下:
import struct
import os
def print_wave_header(f):
'''
Function takes an audio file path as a parameter and
returns a dictionary of metadata parsed from the header
'''
r = {} #the results of the header parse
r['path'] = f
fin = open(f,"rb") # Read wav file, "r flag" - read, "b flag" - binary
ChunkID=fin.read(4) # First four bytes are ChunkID which must be "RIFF" in ASCII …Run Code Online (Sandbox Code Playgroud) 我想在我的网站上修复 WAVE 工具中的错误:http : //human2.com.pl/,错误是:
包含错误的代码:
<form action="<?php echo esc_url( home_url( '/' ) ); ?>" class="search-form searchform clearfix" method="get">
<div class="search-wrap">
<input type="text" placeholder="<?php esc_attr_e( 'Szukaj', 'colormag' ); ?>" class="s field" name="s">
<button class="search-icon" type="submit"> Klik</button>
</div>
</form><!-- .searchform -->
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我修复它吗?谢谢
我正在尝试增加代码中声波的振幅。我有一个缓冲区,其中包含制作波形所需的所有字节。
这是我的音频播放代码:
public void AddSamples(byte[] buffer)
{
//somehow adjust the buffer to make the sound louder
bufferedWaveProvider.AddSamples(buffer, 0, buffer.Length);
WaveOut waveout = new WaveOut();
waveout.Init(bufferedWaveProvider);
waveout.Play();
//to make the program more memory efficient
bufferedWaveProvider.ClearBuffer();
}
Run Code Online (Sandbox Code Playgroud) wave ×10
python ×5
audio ×3
scipy ×3
android ×1
bit-depth ×1
c# ×1
file-io ×1
java ×1
javascript ×1
materialize ×1
math ×1
naudio ×1
numpy ×1
python-2.7 ×1
python-3.x ×1
ripple ×1
sox ×1
string ×1
wav ×1