convert.me
来自「speech signal process tools」· ME 代码 · 共 681 行 · 第 1/2 页
ME
681 行
.lpIf you have several non-ESPS binary files and wish to deal with themas a single FEA file, with each FEA record containing the union of thecorresponding records in the non-ESPS files, convert both to FEA filesusing \fIaddfeahd\fP and then merge them using \fImergefea\fP or\fIfea_deriv\fP and \fImergefea\fP..lpIf the non-ESPS files contain single-channel sampled data and you wishto obtain a multichannel FEA_SD file, use \fIbtosps\fP followed by\fImux\fP (going the other way, use \fIdemux\fP and \fIbhd\fP). .sh 2 "Tags".lpTags in FEA files are a historical holdover from our pre-FEA days, andthey are somewhat of a sore thumb \- they are handled as a specialcase rather than as just another field. That is why the tag alwaysappears first in the record (regardless of whether \fItype_order\fP or\fIfield_order\fP was specified), and why the self-description doesnot include a field named "tag" (an item in the universal headersection specifies whether or not tags are present)..lpIn a later release, we will revise tags to become just another FEAfield. In the meantime, there is no easy way to import a binary fileand have it be tagged. When a tagged file is exported (via \fIbhd\fP),the first element in every record always contains the tag value. .sh 2 "CODED Types".lpOne of the supported FEA data types is CODED. This means that theinformation is an enumerated type \- a discrete set of symbolicvalues. In the ESPS implementation, the values are stored in the FEArecords as SHORTs. The self-description (in the type-specific part ofthe header) contains an array of ASCII strings with the correspondingsymbolic values. Thus, if a FEA file has fields of type CODED, youshould keep in mind that the beheaded file has SHORTs in theappropriate places..lpWhen importing binary data, keep in mind that the current version of\fIaddfeahd\fP does not handle CODED types; although there's noproblem with the data values themselves (which are SHORTs), there's nomechanism for specifying the ASCII strings that denote the symbolicvalues. A workaround is to import the data specifying SHORT as thetype, and then use \fIfea_edit\fP to edit the self-description of theFEA file produced by \fIaddfeahd\fP (change the data type for thefield from SHORT to CODED, and add the list of symbolic values)..sh 1 "DEALING WITH ASCII DATA".sh 2 "Converting from ESPS Files to ASCII".lpAlthough \fIepsps\fP produces an ASCII listing of any ESPS file, andhas various options for tailoring that listing, the data is alwaysannotated in some way. Thus, \fIepsps\fP is more useful for producing"pretty printed" text that people read than it is for producing ASCIIdata streams for other programs. The latter function is supported by\fIpplain\fP, which produces unadorned ASCII data. For example, herewe produce and print 5 Gaussian noise values:.nf.ft CW %testsd -p5 -T gauss - | pplain - 661.176 206.604 347.733 -561.82 432.024 .ft LR.fiBy default, \fIpplain\fP produces data for all fields in every record,but there are options for restricting the output to particularrecords, particular fields, and particular elements within fields..lpIf what is desired is an ASCII stream that contains a function of thedata in each FEA record (rather than the data itself), then theprogram \fIselect\fP can be used (\fIfeafunc\fP may also be useful).For example, suppose the FEA records in the file "speech.fea" includea vector field containing reflection coefficients ("rc") and a scalarfield containing power ("power", and suppose you need to have for eachrecord a stream containing the result of multiplying the square rootof the power by the first reflection coefficient (don't ask me why!).Here's how to do it with select:.nf.ft CW %select -e "sqrt(power)*rc[0]" speech.fea > data.ascii.ft LR.fi.lpSometimes it is desirable to produce "pretty printed" text in a formatother than that produced by \fIepsps\fP; for example, one might wantone FEA record per line with selected field data in different columns.Such a function is provided by \fIfea_print\fP; an ASCII input filenames the elements to be printed from each record and provides acorresponding (C program) format specification. A common use of\fIfea_print\fP is to print one FEA record per line with selectedfield elements appearing in different columns. For For example, suppose that \fIstylefile\fPcontains the following:.nf.ft CW layout=example header1= **************** OUTPUT ****************\\n raw_power[0] power: %5.2f frame_type[0] \ttype: %s spec_param[0] \tRCs: %4.2f spec_param[3,5:6] %4.2f spec_param[7] %4.2f\\n.ft LR.fiInvoking this layout with a FEA_ANA file would result, for example, in the following: .nf.ft CW %fea_print -r 10:14 -l example stylefile speech.fana **************** OUTPUT **************** power: 52.78 type: VOICED RCs: 0.92 -0.36 -0.29 -0.04 -0.29 power: 55.71 type: VOICED RCs: 0.92 -0.36 -0.29 -0.04 -0.29 power: 506.98 type: VOICED RCs: 0.92 -0.36 -0.29 -0.04 -0.29 power: 154.47 type: UNVOICED RCs: 0.31 -0.27 -0.22 -0.05 -0.19 power: 9143.28 type: UNVOICED RCs: 0.31 -0.27 -0.22 -0.05 -0.19.ft LR.lpMost ESPS header items can be obtained in ASCII by means of\fIhditem\fP..sh 2 "Converting from ASCII to ESPS Files".lpTo create a new FEA file from ASCII data or to add a new field to anexisting FEA file, use \fIaddfea\fP. Here's an example:.nf.ft CW %echo "2 4 6 8 10 12" | addfea -f data -s 2 -c"create file" - foo %echo "10 20 30" | addfea -f more_data -c"add some data" - foo %epsps -H foo Record 1: data: 0: 2 4 more_data: 10 Record 2: data: 0: 6 8 more_data: 20 Record 3: data: 0: 10 12 more_data: 30 .ft LR.fiThe first command created a new, three-record file with a field ofsize 2 named "data" in each record. The second command added asecond, scalar field ("more_data") in each record..lpA second approach for converting from ASCII to FEA (but not adding to an existing file) is to use \fIaddfeahd\fP. This is the same program that was discussed earlier in the contextof creating an ESPS header for a file of binary data. \fIAddfeahd\fPoperates more-or-less the same way with ASCII data. For example, .nf.ft CW %addfeahd fields.a test.ascii test.newfea.ft LR.fiwill convert the ASCII file test.ascii to the FEA file test.newfea according to the format specifications in fields.a, which might look like this: .nf.ft CW.ta .2i 2i 3i 3.75i voiced_fraction FLOAT 1 %f raw_power FLOAT 1 %f lpc_power FLOAT 1 %f p_pulse_len FLOAT 1 %f spec_param FLOAT 10 %f frame_len LONG 1 %ld num_pulses LONG 1 %ld.ft LR.fiThis looks just like the case for binary data, except that there's an additional column giving the \fIfscanf\fP() formatto use when scanning the data. .sh 3 "ASCII Sampled Data" .lpASCII sampled data can be imported by means of \fIaddfea\fP (use-\fBT\fP FEA_SD to set the subtype, and \fIaddgen\fP to set the \fIrecord_freq\fP generic), but \fItestsd\fP has an option (\fB-a\fP)that often is more convenient. For example, here we create a complexFEA_SD file with three samples: .nf.ft CW %echo "5 6 10 11 15 16" | testsd -r 10000 -t double_cplx -a - foo.feasd %epsps -H foo.feasd 1: [ 5.0000, 6.0000][ 10.0000, 11.0000][ 15.0000, 16.0000].ft LR.fi\fITestsd\fP does not provide for multi-channel output; for this case, use the \fIaddfea\fP/\fIaddgen\fP combination:.nf.ft CW %echo "2 100 4 110 6 120 8 130" > data %addfea -f samples -T FEA_SD -s 2 -t short data data.feasd addfea: Please enter comment, ended with blank line: This is an example. %addgen -g record_freq -t double -v 10000 data.feasd %epsps -H data.feasd Record 1: samples: 0: 2 100 Record 2: samples: 0: 4 110 Record 3: samples: 0: 6 120 Record 4: samples: 0: 8 130 .ft LR.fi.sh 1 "CONVERTING SAMPLED DATA FROM OTHER FORMATS".lpSampled data files written by STI's Interactive Laboratory System(ILS) system can be converted directly to ESPS FEA_SD files using\fIils2esps\fP. Similarly, sampled data files written by Concurrent's(Masscomp's) Laboratory Work Bench (LWB) can be converted using\fIlwb2esps\fP. .lpConversions between headerless mu-encoded sampled data and ESPS FEA_SDfiles are available by means of \fImu2esps\fP and \fIesps2mu\fP. .sh 1 "INFORMAL ASCII COMMENTS".lpAs illustrated in some of the examples above, most of the conversionprograms insist on being provided with an ASCII comment, which isintended to describe the data being converted and thereby providea starting point for the automatic record keeping facilities of theESPS file system (see the Applications Note: "File Headers and RecordKeeping in ESPS"). This comment can be provided directly on thecommand line (\fB-c\fP), indirectly through a prepared file(\fB-C\fP), or in response to a program prompt. Additional commentscan be added at any time using \fIcomment\fP. .sh 1 "USING DEFAULT HEADERS FOR HEADERLESS FILES".lpIn some situations \- for example, the case of very large files \- itcan be inconvenient to convert headerless files to ESPS in order torun ESPS programs on the data. One can avoid this by alwaysperforming an "on-the-fly" conversion on a pipe, for example:.nf btosps large.sd - | [esps-programs]or addfeahd format large.data - | [esps-programs].lpThis can get clumsy (and it does consume extra processes), so ESPS provides a general mechanism to put "virtual" or "default" headersin front of headerless binary data. .lpIn particular, if any ESPS program does not recognize an input file (tobe precise, it's \fIread_header\fP (3\-\s-1ESPS\s+1) that's doingthis), the file is assumed to be "headerless". If in this case the\fIunix\fP environment variable DEF_HEADER is defined and points to afile with a valid ESPS header (whether or not there is data in thatfile is irrelevant), the header of that file is used as a "virtual"header for the headerless file. Thus, the data description in theDEF_HEADER should be valid for the input data. The ESPS conversionprograms \fIbtosps\fP and \fIaddfeahd\fP are useful in creating suchheaders. Here's an example that creates a 12 Khz FEA_SD header and uses it to filter a headerless data file sg1.a1:.nf %btosps -f 12000 -c "header for sg1" /dev/null k12.hd %setenv DEF_HEADER `pwd`/k12.hd . . . %filter -F data/sg1.filt data/sg1.a1 sg1.a1.filt.sd %send_xwaves make file sg1.a1.filt.sd.fiThe last command sends an \fIxwaves\fP+ display server a command todisplay the filtered file. Note that the output files are ESPS files(i.e., they have ESPS headers). Note also that this approach is notlimited to sampled data. DEF_HEADER can point to any FEA header, andit will "do the right thing" with any FEA-eating program, providedthat the header properly describes the data..sh 1 "FILES WITH FOREIGN HEADERS" .lpIf data files have foreign headers, it can be convenient to leave themin place during ESPS processing, so that they are left when a finalESPS \fIbhd\fP is run. To support this, \fIbtosps\fP, \fIaddfeahd\fP,and \fIbhd\fP have options to leave skipped data (the foreign header)in place, for example:.nf btosps -S 512 -F for.sd - | filter -F esps.filt - - | bhd -F - for.filt.sd.fiThe \fB-F\fP option on \fIbtosps\fP causes the 512 skipped bytes to bekept in place between the ESPS header and the data. Actually, it iskept there by means of new generic header items in the ESPS header, sothat it will be carried along by later programs (like \fIfilter\fP,above). The \fB-F\fP option on \fIbhd\fP causes the foreign header tobe left in place after the ESPS header is removed. The result, in theabove case, is a pipe that starts and ends with a file in the foreignformat..lpForeign headers are kept in the ESPS header in the following manner:The generic header item \fIforeign_hd_length\fP contains the size (inbytes) of the foreign header. If this item is present (and non-zero),\fIread_header\fP() will read this many additional bytes of data, putit into the header, and set an additional generic header item\fIforeign_hd_ptr\fP to point to it. From that point on, the foreignheader is just part of the ESPS header. Note that one can use\fIaddgen\fP (1\-\s-1ESPS\s+1) to modify \fIforeign_hd_length\fP inthe header specified by DEF_HEADER before calling an ESPS program..lpWith this mechanism, it is possible to write programs that use the ESPS header and record I/O functions while still havingaccess to the foreign header. The procedure is simple: use \fIread_header\fP() to read the ESPS header, and \fIget_genhd\fP() to get the pointer to the foreign header.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?