我想用 C# 将提示(即基于时间的标记,而不是类似 ID3 的标记)写入 WAV 文件。NAudio 和 Bass.NET 等免费 .NET 音频库似乎不支持此功能。
我找到了Cue Tools的来源,但它完全没有文档记录并且相对复杂。还有其他选择吗?
通常 wav 文件的 subchunk1size 是 16。但是,我有一些 subchunk1size = 18 的 wav 文件。我有 C++ 代码来读取 subchunk1size = 16 的 wav 文件。现在我想读取 subchunk1size = 18 的 wav 文件。任何帮助,将不胜感激。
typedef struct header_file
{
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;
char subchunk2_id[4];
int subchunk2_size;
} header;
Run Code Online (Sandbox Code Playgroud)
上面是我的代码中的struct header_file,用于读取subchunk1size = 16的wav文件。
我有一些波形文件 (.wav),我需要将它们转换为 base64 编码的字符串。你能指导我如何在 Python/C/C++ 中做到这一点吗?
假设我的 WAV 文件包含 16 位 PCM,我如何将 wav 文件读取为双数组:
using (WaveFileReader reader = new WaveFileReader("myfile.wav"))
{
Assert.AreEqual(16, reader.WaveFormat.BitsPerSample, "Only works with 16 bit audio");
byte[] bytesBuffer = new byte[reader.Length];
int read = reader.Read(bytesBuffer, 0, buffer.Length);
// HOW TO GET AS double ARRAY
}
Run Code Online (Sandbox Code Playgroud) 我有一个使用声音播放器播放 .wav 文件的应用程序,我查找了它,但找不到更改其播放音量的方法。我正在寻找的是通过独立更改文件的音量程序或有一个滑块来更改 Windows 音量混合器中窗口本身的音量。谢谢!
public void loadSound()
{
sp.Load();
sp.Play();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (BarTimer.Value < BarTimer.Maximum)
{
BarTimer.Value = BarTimer.Value + 1;
}
if(BarTimer.Value==BarTimer.Maximum)
{
loadSound();
timer1.Stop();
BarTimer.Value = BarTimer.Minimum;
}
}
Run Code Online (Sandbox Code Playgroud) 假设我有一堆 mp3 文件。我将如何使用音频软件命令行工具在音频文件的一侧(右侧)完全降低音量,而在音频文件的左侧保持完整?然后我想将此文件保存到一个新的 mp3 文件中。这需要完全通过命令行完成。
作为另一种方法。是否可以使用命令行音频文件工具将立体声 mp3 文件转换为单声道,然后将此单声道文件与相同长度的“无声”音轨合并,创建带有声音的左耳机音轨和右耳机音轨用沉默跟踪?
在这个 SO 问题中,似乎有许多方法可以实现一个相当古怪的最终目标。在第一种可能的解决方案中,我只想减小右侧的音量。在第二种可能的解决方案中,我想结合一些更常见的步骤来实现相同的最终结果。
这里的问题是:
谢谢你的帮助。Audacity 通常是我的首选,但它似乎只是 GUI。
我一直在尝试使用 32 位深度的 AudioRecord 在 android 上录制人声并将其写入 wav 文件。我知道只有在 API 级别 23 或更高级别(根据文档所述)使用AudioFormat.ENCODING_PCM_FLOAT. 我在 API 级别 23 的设备上做了一些测试,但由于某种原因,生成的音频已损坏(我只能听到完整的噪音)。我的代码如下所示:
private AudioRecord mRecorder;
private int mBufferSize;
private Thread mRecordingThread;
private boolean mIsRecording;
private String tempPath = "/some/path/tempFile.wav";
private String outputPath = "/some/path/recording.wav";
@TargetApi(23)
public void startRecording() {
mBufferSize = AudioRecord.getMinBufferSize(16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_FLOAT);
mRecorder = new AudioRecord(MediaRecorder.AudioSource.MIC, 16000, AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_FLOAT, mBufferSize);
if (mRecorder.getState() == AudioRecord.STATE_INITIALIZED
&& mBufferSize != AudioRecord.ERROR_BAD_VALUE) {
return;
}
mRecordingThread = new Thread(new Runnable() {
@Override
public void …Run Code Online (Sandbox Code Playgroud) 我是音频编辑库 - Pydub 的新学习者。我想使用 Pydub(比如 .wav/mp3 格式文件)更改一些音频文件的播放速度,但我不知道如何制作。我看到的唯一可能解决这个问题的模块是 effect.py 中的加速模块。但是,没有解释我应该如何称呼它。
谁能解释一下如何在 Pydub 中完成这项任务?非常感谢!
(一个相关的问题:Pydub - 如何在不改变播放速度的情况下改变帧速率,但我想要做的是在不改变音频质量的情况下改变播放速度。)
我正在从从 URL 下载的 wav 音频中读取字节。我想将这些字节“重建”为 .wav 文件。我尝试了下面的代码,但生成的文件几乎是静态的。例如,当我下载自己说话的音频时,生成的 .wav 文件只是静态的,但是当我知道音频应该播放我的声音时,我可以听到轻微的改变/失真。我究竟做错了什么?
from pprint import pprint
import scipy.io.wavfile
import numpy
#download a wav audio recording from a url
>>>response = client.get_recording(r"someurl.com")
>>>pprint(response)
(b'RIFFv\xfc\x03\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\x80>\x00\x00'
...
b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
...
b'\xea\xff\xfd\xff\x10\x00\x0c\x00\xf0\xff\x06\x00\x10\x00\x06\x00'
...)
>>>a=bytearray(response)
>>>pprint(a)
bytearray(b'RIFFv\xfc\x03\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00'
b'\x80>\x00\x00\x00}\x00\x00\x02\x00\x10\x00LISTJ\x00\x00\x00INFOINAM'
b'0\x00\x00\x00Conference d95ac842-08b7-4380-83ec-85ac6428cc41\x00'
b'IART\x06\x00\x00\x00Nexmo\x00data\x00\xfc\x03\x00\xff\xff'
b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'
...
b'\x12\x00\xf6\xff\t\x00\xed\xff\xf6\xff\xfc\xff\xea\xff\xfd\xff'
...)
>>>b = numpy.array(a, dtype=numpy.int16)
>>>pprint(b)
array([ 82, 73, 70, ..., 255, 248, 255], dtype=int16)
>>>scipy.io.wavfile.write(r"C:\Users\somefolder\newwavfile.wav",
16000, b)
Run Code Online (Sandbox Code Playgroud) 我已经成功地在 Python 中使用 ffmpeg 将 mp3 文件转换为 wav,以便我可以将它们发布到 Google Speech-To-Text。现在我对 webm 文件有同样的情况,我拥有的旧功能不起作用。它应该将文件转换为 wav 并将其拆分为 15 秒的块。我可以从 webm -file 执行此操作还是需要先将其转换为其他格式?
我用过的功能:
def convert_and_split(filename):
command = ['ffmpeg', '-i', filename, '-f', 'segment', '-segment_time', '15', '-c', 'copy', 'parts/out%09d.wav']
subprocess.run(command,stdout=subprocess.PIPE,stdin=subprocess.PIPE)
Run Code Online (Sandbox Code Playgroud)
编辑。忘了提及该函数目前对 webm -files 的作用。它产生一个out000000000.wav空的wav 文件。在控制台中,我收到如下错误消息:
[segment @ 0x55970b22fe80] Opening 'parts/out000000000.wav' for writing
[wav @ 0x55970b1ffbc0] opus codec not supported in WAVE format
Could not write header for output file #0 (incorrect codec parameters ?): Function not implemented
Run Code Online (Sandbox Code Playgroud)
编辑2。我认为是对的,但想知道是否有更好的方法来做到这一点。
首先,我将文件转换为单声道 wav,然后将其拆分为多个块。请随时指出任何错误或错误。
def convert_webm_to_wav(file):
command …Run Code Online (Sandbox Code Playgroud)