📄 sphere.3
字号:
.\" @(#)sphere.3 90/04/16 NIST;.\" I Speech Recognition Group.\" Stan Janet.\".TH SPHERE 3 "16 April 1990".SH NAMEsphere \- NIST \s+1SP\s-1eech \s+1HE\s-1ader \s+1RE\s-1sources functions.SH SYNOPSIS.nf#include <header.h>#include <sp.h>struct header_t *\fBsp_create_header\fP()struct header_t *\fBsp_open_header\fP(fp,parse_flag,error)FILE *fp;char **error;int parse_flag;int \fBsp_close_header\fP(h)struct header_t *h;int \fBsp_clear_fields\fP(h)struct header_t *h;int \fBsp_get_nfields\fP(h)struct header_t *h;int \fBsp_get_field\fP(h,name,type,size)struct header_t *h;char *name;int *type, *size;int \fBsp_get_data\fP(h,name,buf,len)struct header_t *h;char *name, *buf;int *len;int \fBsp_add_field\fP(h,name,type,p)struct header_t *h;int type;char *name, *p;int \fBsp_delete_field\fP(h,name)struct header_t *h;char *name;int \fBsp_change_field\fP(h,name,type,p)struct header_t *h;char *name, *p;int type;int \fBsp_write_header\fP(fp,h,hbytes,databytes)FILE *fp;struct header_t *h;long *hbytes, *databytes;int \fBsp_format_lines\fP(h,fp)struct header_t *h;FILE *fp;int \fBsp_print_lines\fP(h,fp)FILE *fp;struct header_t *h;.fi.SH DESCRIPTIONThe \fBSPHERE\fP function library supports disk I/O and in-memorycreation and modification of NIST speech file headers.This software has been developed at The National Institute of Standardsand Technology for use within the DARPA speech researchcommunity. Although care has been taken to ensure that all software iscomplete and bug-free, it is made available to the speech researchcommunity without endorsement or express or implied warranties. The abstract data type that programs use is a pointer to a \fIheader_t\fPstructure. This pointer is a handle used by the functions that operateon the header, much like a FILE pointer is used as a handle by functionsin the C \fIstdio\fP library that operate on files.All arguments \fIh\fP in this document refer to a header structurethat has been associated with a header pointer.There are two ways to return a program may obtain a header pointer.The first method is to call.B sp_create_headerwhich returns a pointer to an empty header.The other is to call.B sp_open_headerwhich reads the fields from a NIST SPHERE-format speech fileinto a header data structure.Argument.I fpmust be a file pointer associated with a NIST SPHERE-formatspeech file that has been opened for reading.On success, the file pointer is positioned at the end ofthe header, which is the start of the speech samples.On failure, the argument.I errorwill point to a string describing the causeof the failure.If the.I parse_flagargument is non-zero, the header is parsed and allfields in the header file are associated with the headerstructure. If the argument is zero, the header is not parsedand no fields are associated with the structure.The memory for header structures is obtained dynamically via malloc(3).Therefore, the function.B sp_close_headershould be used to deallocate the memory header structureassociated with a header pointer. This functionuses free(3) to deallocate all memory associated withthe fields in the header structure, then the space forthe header structure itself.The function.B sp_get_nfieldsreturns the number of fields stored in theheader structure associated with a header pointer.The function.B sp_clear_fieldsdeletes all fields from the header structure associatedwith a header pointer.Programs may determine the type and size in bytesof a header field via \fBsp_get_field\fP. Valid typesare T_INTEGER, T_REAL, and T_STRING, which are defined in header.h.The sizes of integer and double fields aresizeof(long) and sizeof(double), respectively.The sizes of strings vary and do not includenull-terminator bytes, since all byte values includingzero are allowed in a stringby the NIST header grammar.The function.B sp_get_datacopies the value of the field specified by\fIname\fP into buffer \fIbuf\fP.No more than.I lenbytes are copied;.I lenmust be positive.A field.I namemay be added to a header by calling.B sp_add_fieldwith a.I typefield of either T_INTEGER, T_REAL, or T_STRING.Argument.I pshould be a pointer to a long, double, or character, respectively,and cast, if necessary, to a character pointer.The specified field must not already exist in the header.A field.I namemay be deleted from a header via \fBsp_delete_field\fP.The function fails if the specified field does not existin the header.An existing field's type and/or value may changedby calling.B sp_change_fieldwith arguments.I typeand.I pas in \fBsp_add_field\fP. A header structure can be written to disk in NIST SPHERE formatvia \fBsp_write_header\fP.Argument \fBfp\fP must be a file pointer associated witha file that has been opened for writing.The format is:.nf.in +.5i.spfieldname -typespec fieldvalue.sp.in -.5i.fiwhere.I typespecis \fIi\fP, \fIr\fP, or \fIs\fPstringlength.On success,.I hbytesand.I databytescontain the total number of bytes written to diskincluding padding and not including padding, respectively.On failure, the variables are undefined.The function.B sp_format_lineswrites the fields to stream.I fpone-per-line.The function.B sp_print_lineswrites a header.I hto stream.I fpin a more-readable format:.nf.in +.5i.spfieldnumber: fieldtype fieldname "fieldvalue".in -.5i`.sp.fiwhere fieldtype is either\fIs\fP, \fIi\fP, or \fIr\fP.Field numbering begins at zero..SH RETURN VALUESAll functions in the library that return pointers return NULLpointers on failure/error.All numeric functions return negative values on failure/error..SH FILES.PD 0.TP 20.B libsp.aSphere library.TP.B header.hbasic type definitions and constants.TP.B sp.hSphere function type definitions.PD.SH NOTESComments in speech headers are ignored when encounteredon input. No mechanism is supportedfor writing comments into headers..SH BUGSPlease report any bugs to John Garofolo by sending email tojohn@jaguar.ncsl.nist.gov.Please include a description of the bug/problem and the hardwareand software under which the problem occurred, as well as any dataneeded to reproduce the problem..SH AUTHORStan Janet (stan@jaguar.ncsl.nist.gov)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -