Question: I found that your vox converter doesn't handle vox files from the Orator phone dictation system right.
Answer: There are so many questions about Vox format. What is the Vox format? Vox audio file format is a headerless audio format data, which generally contains Dialogic_ADPCM, but may also include A-law, Mu-law, PCM, and any other type of audio data.
It means that vox file doesn't have the header and extention ".vox" doesn't say anything at all. Therefore it is very important to know in which format you have the audio data in the vox file!
See code below for the different types of Vox files.
//Dialogic_ADPCM
private static void Vox2Wav(string voxFile, int samplesPerSec)
{
BinaryReader br = new BinaryReader(File.OpenRead(voxFile));
IntPtr format = AudioCompressionManager.GetPcmFormat(1, 16, samplesPerSec);
WaveWriter ww = new WaveWriter(File.Create(voxFile + ".wav"),
AudioCompressionManager.FormatBytes(format));
Vox.Vox2Wav(br, ww);
br.Close();
ww.Close();
}
private void VoxConv2(string voxFile)
{
//CCITT u-Law, 8000 Hz, 1 channels
WaveFormat wf = new WaveFormat();
wf.wFormatTag = AudioCompressionManager.MuLawFormatTag;
wf.nChannels = 1;
wf.nSamplesPerSec = 8000;
FormatDetails[] formatList = AudioCompressionManager.GetFormatList(wf);
IntPtr format = formatList[0].FormatHandle;
RawReader rr = new RawReader(File.OpenRead(voxFile), format);
byte[] data = rr.ReadData();
rr.Close();
WaveWriter ww = new WaveWriter(File.Create(voxFile + ".wav"),
AudioCompressionManager.FormatBytes(format));
ww.WriteData(data);
ww.Close();
}
static void Raw2Wav(string fileName)
{
//A-Law mono at 8000 HZ
WaveFormat wf = new WaveFormat();
wf.wFormatTag = AudioCompressionManager.ALawFormatTag;
wf.nChannels = 1;
wf.nSamplesPerSec = 8000;
FormatDetails[] formatList = AudioCompressionManager.GetFormatList(wf);
IntPtr format = formatList[0].FormatHandle;
RawReader rr = new RawReader(File.OpenRead(fileName), format);
byte[] data = rr.ReadData();
rr.Close();
WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"),
AudioCompressionManager.FormatBytes(format));
ww.WriteData(data);
ww.Close();
}
For more examples of working with vox files you can find on How to.. page. The search string "vox" gives at least 79 matches.
No comments:
Post a Comment