RIFF WAV文件中是否保证格式参数的字节顺序?我听到了相互矛盾的答案,包括对RIFX文件格式的引用.
我正在处理wav文件的幅度并按一些小数因子进行缩放.我试图以有效记忆的方式阅读和重写文件,同时也试图解决语言的细微差别(我是C的新手).该文件可以是8位或16位格式.我想这样做的方法是首先将头数据读入一些预定义的结构,然后在循环中处理实际数据,我将把一大块数据读入缓冲区,做任何需要它,然后将其写入输出.
#include <stdio.h>
#include <stdlib.h>
typedef struct header
{
char chunk_id[4];
int chunk_size;
char format[4];
char subchunk1_id[4];
int subchunk1_size;
short int audio_format;
short int num_channels;
int sample_rate;
int byte_rate;
short int block_align;
short int bits_per_sample;
short int extra_param_size;
char subchunk2_id[4];
int subchunk2_size;
} header;
typedef struct header* header_p;
void scale_wav_file(char * input, float factor, int is_8bit)
{
FILE * infile = fopen(input, "rb");
FILE * outfile = fopen("outfile.wav", "wb");
int BUFSIZE = 4000, i, MAX_8BIT_AMP = 255, MAX_16BIT_AMP …Run Code Online (Sandbox Code Playgroud) 我有2个音乐会的音频输入.第一个是wav文件,第二个是麦克风实时拍摄.我需要与麦克风输入同步播放第一个文件.
我可以使用哪个库?
有没有这方面的教程,指南或示例?
谢谢
我有一个mp4格式的电视片段,包含音频和视频,以及一个WAV audio_commentary轨道.
我一直在尝试将它们组合在ffmpeg中,然后使用flash播放器在线播放(只能采用h264格式)
完成此任务的最佳ffmpeg命令是什么?我的输入是MP4视频,WAV音频和以秒为单位的偏移量,音频评论开始的时间相对于mp4视频的开始.
我试过了
ffmpeg -i input_audio.wav -i input_vid.mp4 -vcodec copy output.mp4
Run Code Online (Sandbox Code Playgroud)
和
ffmpeg -vcodec copy -ss offset -i input_audio.wav -i input_video.mp4 output.mp4
Run Code Online (Sandbox Code Playgroud)
下面这些做我想做的事情并以h264格式输出对闪存播放器有利的视频 - 有没有办法在ffmpeg中从命令行执行此操作?
我试图在Python中以编程方式拆分wav文件.基于stackoverflow的提示以及Python wave模块的文档,我正在执行以下操作
import wave
origAudio = wave.open('inputFile.wav','r')
frameRate = origAudio.getframerate()
nChannels = origAudio.getnchannels()
sampWidth = origAudio.getsampwidth()
start = float(someStartVal)
end = float(someEndVal)
origAudio.setpos(start*frameRate)
chunkData = origAudio.readframes(int((end-start)*frameRate))
chunkAudio = wave.open('outputFile.wav','w')
chunkAudio.setnchannels(nChannels)
chunkAudio.setsampwidth(sampWidth)
chunkAudio.setframerate(frameRate)
chunkAudio.writeframes(chunkData)
chunkAudio.close()
Run Code Online (Sandbox Code Playgroud)
我迭代了许多不同的开始和结束值,并以这种方式从原始文件中提取音频块.奇怪的是,这种技术对于某些块来说非常好,并且会为其他块产生垃圾白噪声.此外,没有明显的模式,其中开始和结束位置产生白噪声,只是它一直发生输入文件.
以前有人经历过这种行为吗?或者知道我做错了什么?欢迎以编程方式更好地分割音频文件的建议.
提前致谢.
我坚持试图让IE播放WAV文件.我只有WAV文件(大量)并且由于服务器磁盘空间而无法转换它们.
在W3Schools上声明IE不支持HTML5 <audio>标签的WAV格式.(我试过 - 真的没有).
我试过它mediaelement.js并且jPlayer- 没有一个呈现纯粹的解决方案.mediaelement.js只是不播放它只jPlayer需要mp3.
我想省略使用QuickTime插件,因为用户很少拥有它,并且让插件丢失错误真的很令人沮丧.
还有其他方法可以玩吗?
我想使用pyDub将单个单词的长WAV文件(以及其间的静音)作为输入,然后去掉所有的静音,并输出剩余的块是单独的WAV文件.文件名可以只是序列号,如001.wav,002.wav,003.wav等.
Github页面上的" 又一个示例? "示例执行的操作非常相似,但它不是输出单独的文件,而是将静音剥离的段组合在一起形成一个文件:
from pydub import AudioSegment
from pydub.utils import db_to_float
# Let's load up the audio we need...
podcast = AudioSegment.from_mp3("podcast.mp3")
intro = AudioSegment.from_wav("intro.wav")
outro = AudioSegment.from_wav("outro.wav")
# Let's consider anything that is 30 decibels quieter than
# the average volume of the podcast to be silence
average_loudness = podcast.rms
silence_threshold = average_loudness * db_to_float(-30)
# filter out the silence
podcast_parts = (ms for ms in podcast if ms.rms > silence_threshold)
# combine all the chunks back together …Run Code Online (Sandbox Code Playgroud) 我刚开始使用Python并使用PyAudio和Wave模块从我的麦克风中取出声音并将其转换为.wav文件.
我正在尝试做的是现在将其转换.wav为.flac.我已经看到了一些方法,这些方法都涉及安装转换器并将其放置在我的环境路径中并通过它调用它os.system.
有没有其他方法可以转换.wav为.flac通过Python?我正在寻找的解决方案需要在Windows和Linux上运行.
我想使用 pyaudio 和 IBM Bluemix 服务实现简单的语音转文本工具。目前我需要录制音频,将其保存到磁盘,然后再次加载以将其发送到 Bluemix。
RATE=44100
RECORD_SECONDS = 10
CHUNKSIZE = 1024
# initialize portaudio
p = pyaudio.PyAudio()
stream = p.open(format=pyaudio.paInt16, channels=1, rate=RATE, input=True, frames_per_buffer=CHUNKSIZE)
frames = [] # A python-list of chunks(numpy.ndarray)
print("Please speak!")
for _ in range(0, int(RATE / CHUNKSIZE * RECORD_SECONDS)):
data = stream.read(CHUNKSIZE)
frames.append(np.fromstring(data, dtype=np.int16))
#Convert the list of numpy-arrays into a 1D array (column-wise)
numpydata = np.hstack(frames)
# close stream
stream.stop_stream()
stream.close()
p.terminate()
# save audio to disk
wav.write('out.wav',RATE,numpydata)
# Open audio file(.wav) …Run Code Online (Sandbox Code Playgroud) 使用Python 3.7和Tensorflow 2.0,我很难从UrbanSounds数据集中读取wav文件。这个问题和答案是有帮助的,因为它们解释了输入必须是字符串张量,但是要通过文件中编码的初始元数据并获得真实数据似乎很难。我必须先对字符串进行预处理,然后才能将其作为float32张量加载吗?我已经不得不通过将数据从24位wav降采样到16位wav来预处理数据,因此数据输入管道变得比我预期的要麻烦得多。所需的下采样特别令人沮丧。到目前为止,我正在尝试以下操作:
import tensorflow as tf # this is TensorFlow 2.0
path_to_wav_file = '/mnt/d/Code/UrbanSounds/audio/fold1/101415-3-0-2.wav'
# Turn the wav file into a string tensor
input_data = tf.io.read_file(path_to_wav_file)
# Convert the string tensor to a float32 tensor
audio, sampling_rate = tf.audio.decode_wav(input_data)
Run Code Online (Sandbox Code Playgroud)
这是我在最后一步得到的错误:
2019-10-08 20:56:09.124254: W tensorflow/core/framework/op_kernel.cc:1546] OP_REQUIRES failed at decode_wav_op.cc:55 : Invalid argument: Header mismatch: Expected fmt but found junk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/envs/tf2/lib/python3.7/site-packages/tensorflow/python/ops/gen_audio_ops.py", line 216, in decode_wav
_six.raise_from(_core._status_to_exception(e.code, message), …Run Code Online (Sandbox Code Playgroud)