Hallo, wie kann ich eine Audio Datei, aufgenommen mit z.B. Audacity, in in Ascii Werte umwandeln. Hintergrund, ich habe eine Controllerprogramm und möchte den Audiocode dort "durchjagen", sprich eine Simulation fahren. Also gibt es ein Tool um Mono Audiodaten in eine csv datei zu wandeln ? schon mal vielen Dank für eure Hilfe Robert
sox, der Chuck Norris unter den Audioconvertern, kennt ein .dat-Format: "Text Data files. These files contain a textual representation of the sample data. There is one line at the beginning that contains the sample rate. Subsequent lines contain two numeric data items: the time since the beginning of the first sample and the sample value. Values are normalized so that the maximum and minimum are 1 and -1. This file format can be used to create data files for external programs such as FFT analysers or graph routines. SoX can also convert a file in this format back into one of the other file formats." Wenn das nicht so aussieht, wie Du das brauchst, dann würde ich an Deiner Stelle vermutlich selber was programmieren, z.B. mit libsndfile ( http://www.mega-nerd.com/libsndfile/ ) für den Import. Mirko
1 | #!/usr/bin/python
|
2 | |
3 | #benutzen mit
|
4 | # python diesedatei.py in.wav out.csv
|
5 | |
6 | import wave |
7 | import sys |
8 | import struct |
9 | |
10 | infile = wave.open(sys.argv[1], 'r') |
11 | outfile = open(sys.argv[2], 'w') |
12 | num_samples = infile.getnframes() |
13 | for i in range(0, num_samples): |
14 | frame = infile.readframes(1) |
15 | number = struct.unpack('h', frame)[0] |
16 | line = str(i) + ';' + str(number) + '\n' |
17 | outfile.write(line) |
18 | infile.close() |
19 | outfile.close() |
Scheint zu funktionieren und ist leicht anzupassen.
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.