-1

Solved, thanks. It's base64 and this works.

System.Convert.FromBase64String(columns[6]);

Thanks again.

I got a TSV file, and inside this file there're audio stored as original string and related wave info. One wave and its info per line. What I need to do is to read each line, get the audio, and save them as separated wave files. One sample of wave string is like this:

UklGRpgiAABXQVZFZm10ICwAAACUAgEAgD4AAPAKAAA4AAAAGgABAA8AKACOAgEAgD4AANAHAAAoAAAAAgBAAWRhdGFYIgAAQMQKQPQTQTQSQTQSQTQUQYNBVBNBJBJBJBNBJBRBRKFEE0EkE0FEFEE0FEFUFQAAAAAAAAAAAADACOmRY92lbj7+7kGhMFC3V9I3qMyjX2G8vAclkKFxUlD26mS+1qCRMV4OuVCxXf/IxrFBj///9sAG0iRqqUOIIRKT/4vqBtdWJF6pI/mWgPFx6JlUIFUPm6gofbyf93hJ6NCbgja88uTflydp///

And I tried to read this line and use:

byte[] waveContext = Encoding.Default.GetBytes(columns[6]);
File.WriteAllBytes(waveFullPath, waveContext);

But the output file contains just the same string. Does anybody got ideas on how to handle this?

Many thanks.

OnceJune
  • 29
  • 6
  • Looks like base64. Is it? – Stefan Steinegger Jul 03 '15 at 07:55
  • You need to know how the bytes were converted to a string in the first place. You can't just convert arbitrary bytes to a string and get something as 'readable' as that, so there must be a conversion of some sort (e.g. Base64). If so you need to reverse that conversion. – James Gaunt Jul 03 '15 at 07:55
  • Yep, it's Base64 encoded WAV file – phuzi Jul 03 '15 at 07:59
  • Please remove all but the first 4 lines form your example. It makes no sense to waste this space... – DrKoch Jul 03 '15 at 08:06

2 Answers2

0

Looks like a base 64 encoded string.

 byte[] waveBytes = System.Convert.FromBase64String(base64EncodedData);

Don't know how to build up a wave file. This may help you: MSDN: Creating wav files in C#. (10secs lookup with Google.)

Stefan Steinegger
  • 63,782
  • 15
  • 129
  • 193
0

There is no such thing as "audio stored as original string".

Audio data is binary data usually (these days) two channels à 16Bits interleaved prepended by a short (binary) header which contains number of channels and sampling rate.

Read about "RIFF WAV" file format.

DrKoch
  • 9,556
  • 2
  • 34
  • 43