1
2<sect>Text-To-Speech Control Protocol (version 0) <label id="ttscp">
3<p>
4
5TTSCP is a client-server connection-oriented,
6both human- and machine-readable communication protocol,
7remotely similar to the File Transfer Protocol in spirit.
8TTSCP is offered as a standard interface for controlling
9generic speech processing applications, not only Text-To-Speech ones.
10It is primarily designed to run atop TCP, but any reliable
11connection-oriented underlying protocol should theoretically
12work as well.
13
14The server awaits new connections on a single TCP port.
15There are two types of connections: <em/control connections/
16used to issue commands by the client and to return status
17information, such as completion messages by the server,
18and <em/data connections/ used to transfer the actual data.
19Immediately after the underlying connection is opened,
20the server transmits a <em/session header/ (see below)
21and treats the connection as a control connection, until
22the <tt/data/ command is issued by the client, causing
23it to become a data connection.
24
25Every TTSCP connection (both a control one and a data one) obtains
26a connection handle from the server inside the session header.
27This handle is a string of alphanumeric characters which
28uniquely identifies the connection and which also serves
29as an access token for it. Other connections can use such
30a handle to interrupt a control connection's task in progress,
31to disconnect any connection, to process data received from
32a data connection etc.
33
34A <em/TTSCP session/ is a sequence
35of commands, their results and referenced data lasting
36from setting up the control connection until its disconnection
37or the <tt/data/ command.
38Any party may quit the session at any time, but must advise
39the other one either by the <tt/done/ command (the client)
40or by a <tt/600/ response code or higher (the server).
41If a <tt/done/ command is sent before a preceding command
42has completed, the server will proceed with the
43preceding commands. If a <tt/600/ or higher error code
44is received as a response to a command and subsequent commands
45have already been sent by the client, they will not be executed.
46
47A data connection may be silently disconnected by the client
48at any time.  To allow reliable disconnection detection by the
49server, every data connection is attached to an already
50existing control connection (as specified with the <tt/data/
51command) and it will be automatically disconnected when
52the control connection is disconnected.  This attachment relation
53doesn't prevent other control connections from referencing this
54data connection using its handle, it only limits its lifetime.
55
56The session header (as sent before a TTSCP session starts)
57is a sequence of lines.  The first line
58shall exactly match the string <tt/TTSCP spoken here/; the clients
59are strongly encouraged to use this string to identify the protocol.
60Each of the following lines contains
61a TTSCP header keyword terminated by a colon and a single space
62and the value associated with the keyword. The client may choose
63not to use these values at all, or to scan only for some header
64keywords.  The last line in the header shall contain the <tt/handle/
65keyword.
66
67A typical TTSCP session looks like this, with client commands
68unindented and server responses indented.
69
70<tscreen><verb>
71	TTSCP spoken here
72	protocol: 0
73	extensions:
74	server: Epos
75	release: 2.4.6
76	handle: O29-m2UZ
77user user&commat;host.domain.net
78	452 user not found
79setl some_option on
80	200 OK
81strm $zC-4EEl0:raw:rules:diphs:synth:/dev/dsp
82	200 OK
83appl 34
84	112 started
85	122 total bytes
86	 3622
87	123 written bytes
88	 3622
89	200 OK
90done
91	600 goodbye
92</verb></tscreen>
93
94
95The "user" and "done" commands may become mandatory, the rest may
96be freely used between them. For the interaction with a human, the
97"help" command is available.
98
99It is legal to use "anonymous" instead of the address in the user
100command: "user anonymous". It is also legal to switch users
101with additional user commands. This may cause context switches.
102
103It is advised to check the greeting string received to begin in
104"TTSCP ". If it doesn't, the client or possibly the
105server may be obsolete or an unrelated protocol may be used at the
106port.
107
108In this document, a "newline" produced by the server or the client should be
109a <tt/CR LF/ character sequence.  It is allowed for both parties to
110accept a <tt/LF/ character without a preceding <tt/CR/ character as a valid
111line separator, but it is never legal to rely on this practice.
112
113<sect1>Session Header Keywords
114<p>
115
116The set of session header keywords and their sequence may vary between
117TTSCP implementations.  Some lower case keywords are defined by this document;
118in addition, any implementation may supply its own keywords provided
119their first two characters are lower case <tt/x/ and dash, respectively,
120or they consist solely of upper case letters.  Both standard and
121implementation specific keywords are limited to upper and lower case
122letters (case sensitive), digits, dashes and underlines;
123however, the values associated with some keywords may contain any printable
124ISO 8859 characters.  There are three mandatory keywords
125(<tt/protocol/, <tt/extensions/ and <tt/handle/, in order of appearance
126in the session header).
127
128<descrip>
129<tag>extensions</tag>
130	The value is a whitespace separated list of semi-standard and non-standard
131	extensions supported by this TTSCP server.  Only extensions defined by
132	this document or a future version of this document should be advertised;
133	custom or experimental extensions may be advertised provided their
134	first two characters are lower case <tt/x/ and dash, respectively.
135	At present, there are no extensions defined, so the list should be empty,
136	but this keyword is nevertheless mandatory.
137<tag>handle</tag>
138	The value is a connection handle for this control connection. The handle
139	stays valid when the connection is turned into a data connection.  Only
140	lower and upper case letters, digits, dashes and underlines may occur in
141	the handle.  This keyword is mandatory and must appear last in the session
142	header.
143<tag>protocol</tag>
144	The value is a decimal number identifying the major TTSCP protocol version.
145	The current protocol version number is <tt/0/ (previous versions had no
146	session header).  It is likely that protocol versions unknown to the
147	client will be fundamentally incompatible.  It is mandatory to begin the
148	session header with this keyword.  It is recommended to check it on the
149	client side.
150<tag>release</tag>
151	Server release.  The formatting and interpretation is implementation dependent.
152<tag>server</tag>
153	Server name.  Different versions of the same implementation should
154	typically use an identical value for this keyword.
155</descrip>
156
157
158<sect1>Data Formats<label id="formats">
159<p>
160
161The data is passed between modules in one of the following formats:
162
163<itemize>
164	<item> plain text
165	<item> phonetic structure of the text (TSR)
166	<item> Speech Synthesizer Input Format (SSIF)
167	<item> sequence of segments
168	<item> waveform file
169</itemize>
170
171<sect2> Plain Text
172<p>
173This is what the "text" in "text-to-speech" stands for.
174
175<sect2> Text Structure Representation
176<p>
177Internal text representation, suitable for arbitrary processing, but
178unsuitable for input or output. Before output, it must be converted
179to another format first. For a description, see the <ref id="tsr"
180name="text structure representation overview">.
181
182Conversion to plain text dismisses prosody.
183
184Conversion to plain text dismisses segment layer if any.
185
186<sect2> Speech Synthesizer Input Format
187<p>
188
189This format has been introduced by the MBROLA synthesizer
190development team.  Together with the "sequence of segments"
191it is one of the two possible input formats to a speech
192synthesizer in Epos.  With the MBROLA synthesizer you have
193to use SSIF.
194
195SSIF is line oriented, each line corresponding to a single phone;
196the line contains several whitespace separated components.
197
198The first component is the SAMPA notation of the phone;
199the second component is its duration in milliseconds.
200
201Subsequent components are prosody points.  Each prosody point
202is enclosed in parentheses and consists of two or three
203integers separated by commas.  The first value locates
204the prosody point within the phone per cent (e.g. the value
205of <tt/99/ corresponds to just before the end of the phone);
206the second value indicates the desired pitch at that prosody
207point (the value of <tt/100/ indicates the default pitch);
208the third value, which is not currently supported by MBROLA,
209and which is optional, indicates the intensity at that point.
210It is the responsibility of the synthesizer to do piecewise
211linear interpolation between prosody points.
212
213<sect2> Sequence of Segments
214<p>
215
216Every segment is a quadruple of segment number, assigned frequency (pitch),
217intensity (volume) and time factor (speed). The initial segment is dummy
218(to be skipped); its segment number contains the total number of segments
219in this sequence. The corresponding prosodic parameters are undefined.
220They should preferably be zero.
221
222The integer values should be encoded as 32-bit little endian
223integers.
224
225This format is currently being replaced by SSIF, although it will
226remain to be supported for some additional period time.
227
228<sect2> Waveform
229<p>
230The traditional MS Windows RIFF <tt/.wav/ file header and data.
231Two liberties may be taken when waveform data in this format is sent
232via a data connection.
233
234First, the total length of the RIFF form field
235may contain a negative number.  In this case, the length
236of the form shall be determined from the data length as indicated
237in the corresponding TTSCP control connection.  Also, if this
238field contains a positive number, which conflicts with the data
239length indicated in the corresponding TTSCP control connection,
240the recipient may choose any one of them or return a <tt/435/ error.
241
242Second, if only <tt/fmt/ and <tt/data/ chunks are present in the
243RIFF form being sent, and the length of the data chunk is negative,
244the length of the <tt/data/ chunk shall be determined from the
245total length of the RIFF form. (Epos never actually takes advantage
246of this rule.)
247
248This format allows storing labels (i.e. pointers to specific
249positions within the waveform); Epos does use this feature
250if enabled e.g. using the <ref id="labelphones-option" name="label_phones option">
251to label phone and/or segment boundaries within the waveform.
252
253<sect1> TTSCP Commands
254<p>
255
256TTSCP commands are newline-terminated strings. Each of them begins
257with a command identifier, some of them may continue with optional
258or mandatory parameters, depending on the particular command.
259Each command generates one or more "replies", the last reply
260indicating completion and sometimes also some command-specific
261information.
262
263<sect2> <tt> appl </tt> <label id="appl-cmd">
264<p>
265
266Apply the current data processing stream (see the <ref id="strm-cmd" name="strm command">
267to some data. The parameter is a decimal number specifying the number
268of bytes to be processed.
269
270Before the completion reply, zero or more 122 replies are received
271by the client, every one followed by a decimal number on a line
272by itself, preceded with a single space. This is the number of
273bytes written by the output module per task.  Usually, if the <tt/appl/
274command generates a single successful task only, there shall be exactly
275one such reply, but if e.g. the <ref id="chunk-mod" name="chunk"> module has split the
276input text into more independent parts, multiple outputs and
277multiple 122 replies may appear; if e.g. the <ref id="join-mod" name="join"> module has
278been employed, there may be no 122 reply at all if the text being
279processed is considered unterminated.
280Such an intermediate reply should be sent as soon as the number
281of bytes to be sent is known to the TTSCP server to avoid certain
282deadlock scenarios caused by an insufficient buffer capacity between
283the server and the client. The number of bytes actually sent may
284be even smaller in case of a user break or another unexpected situation;
285it shall never be larger and it shall be exactly the number of bytes
286sent by the server upon a successful completion reply.
287
288Before the completion reply, one or more 123 replies for every 122 reply
289are received
290by the client. Every 123 reply is followed by a decimal number
291on a line by itself, preceded with a single space.  This is the
292number of bytes actually successfully written by the output module.
293This intermediate reply should be sent as soon as the data is
294sent.  When the client eventually receives a successful completion reply,
295the sum of byte counts received with 123 replies shall match
296the number of bytes sent by the server.
297
298For every 122 reply, there shall be a corresponding sequence of 123 replies
299such that no unrelated 122 or 123 replies intervene.  The sum of byte counts
300received with these 123 replies shall match the byte count received with
301the 122 reply.  In other words, the replies relating to different subtasks
302must preserve the time ordering.  If an error condition prematurely terminates
303the <tt/appl/ command processing, this behavior is not required for
304the last subtask whose processing has begun, independent of whether
305its 122 reply has been received by the client.
306
307The relative ordering of 122 and 123 replies for the same subtask
308is not specified by the TTSCP.
309
310The completion response code is received when all the modules have
311finished processing and data has been output by the output module.
312Some of the data may however still be being processed by hardware,
313e.g. a sound card, or may be delayed by the network.
314
315Using <tt/appl/ before the first <tt/strm/ command is forbidden.
316
317<sect2> <tt> intr </tt>
318<p>
319
320Interrupt a single <tt/appl/ command in progress. The parameter is a control connection
321handle and specifies the connection which issued
322the command to be interrupted.
323
324The server should try to discard as much pending data as possible,
325including e.g. waveform data already written to a sound card.
326If however multiple <tt/appl/ commands have been sent simultaneously,
327only the one in progress will be interrupted.
328
329The server will reply a 401 completion code to the interrupted
330connection, whereas a 200 completion code will acknowledge
331a successful <tt/intr/ command.
332
333If there is no stream associated with the connection to be interrupted
334or there is no apply command in progress on it, a 423 reply will be
335issued to the interrupting connection and the interrupting connection
336will not be affected.
337
338<sect2> <tt> data </tt>
339<p>
340
341Turn this control connection into a data connection. The parameter
342is the handle of an existing control connection to attach this connection to.
343The sole consequence of this attachment relation is a disconnect of the
344data connection when the specified control connection is disconnected.
345(It is therefore common for a client to open two connections, to get their
346connection handles, to turn one into a data connection and to attach it
347to the other connection.  That way the client obtains a control and a data
348connection which will gracefully shutdown even after the client abruptly
349disconnects.)
350
351The server sends a completion reply for this command (response code 200 if successful).
352After the first newline character following the 200 response code is received,
353no more control information will arrive. Likewise, the client may not send any
354TTSCP commands after the newline-terminated data command.
355If the <tt/data/ command is not successful because of capacity or other reasons,
356the connection stays in a valid
357TTSCP control connection state and more commands may be submitted.
358
359The data connection becomes valid at receipt of a 200 response code to
360this command.
361
362<sect2> <tt> delh </tt>
363<p>
364
365Terminate a specified data connection. The parameter is the data connection handle
366to be terminated, as returned by a former <tt/data/ command on that connection.
367If successful, the connection is disconnected by the server and the data connection
368handle is forgotten.
369
370<sect2> <tt> done </tt>
371<p>
372
373Issued as the last command in a session. The client may exit just
374after sending this command. The server should reply with error
375code 600.
376
377<sect2> <tt> down </tt>
378<p>
379
380Stop the server. Quit pending sessions. May disappear in the future.
381
382<sect2> <tt> help </tt>
383<p>
384
385Request for TTSCP syntax help. The server response is undefined
386except for the proper error code termination (class 2 or 4).
387
388Suggested behavior is to reply with "441 help yourself"
389or a brief list of commands with explanation.
390If a parameter is given, the server may supply more
391specific information, such as verbose description of a single
392command.
393
394The usual completion reply rules apply. Specifically, care
395must be taken lest the help text contain a line beginning
396with a digit.
397
398<sect2> <tt> pass </tt>
399<p>
400
401Attempts to validate an account, as given by a previous "user"
402command. If no valid "user" command was ever received, the internal
403server password may be used. This may enable some internal commands
404such as "down" or "setg".  (Epos stores this internal password
405in /var/run/epos.pwd while it is listening on the standard
406TTSCP port.)
407
408The password is a string of alphanumeric characters, dashes and
409underlines, no more than 250 bytes long.
410
411<sect2> <tt> setg </tt>
412<p>
413
414Globally set a server configuration parameter. The parameter is
415a whitespace-separated "option value" pair. The server may ignore
416this command altogether with an error code 442. The server will
417reply with an error code 412 if the value assigned is illegal,
418or with 451 if the server is configured not to allow to change
419this parameter (may depend on the current authentication status).
420
421The settings, if successful, will apply to all future connections.
422They will typically not affect existing connections, unless specified
423otherwise. For this reason, this command should be available only
424to authenticated and trusted users.
425
426If the option name is "language", the command will attempt to
427switch the default language. The same goes for "voice".
428
429The standardization status of this command is still unclear.  It is definitely
430reasonable to use compatible option names between server implementations
431where applicable, but the set of useful configuration parameters
432seems to be impossible to specify in advance.
433Any comment on this issue is welcome.
434
435<sect2> <tt> setl </tt>
436<p>
437
438Set a server configuration parameter. The parameter is a whitespace-separated
439"option value" pair. The server may ignore this command altogether
440with an error code 442. In any case, this setting should never
441alter the execution environment of existing and/or future sessions.
442(In Epos, setting a static option using <tt/setl/, which is rarely
443allowed and even less often actually done, affects all connections
444in the same way; but all voice, language and global options
445fully follow this standard.)
446The server will reply with an error code 412 if the value assigned
447is illegal, or with 451 if the server is configured not to allow
448to change this parameter (may depend on the current authentication status).
449
450The settings apply to the current session; use <tt/setg/ for more
451permanent settings.  Note also that setting some options can have
452arbitrary side-effects.
453
454If the option name is "language", the command will attempt to
455switch the language. The same goes for "voice".
456
457The standardization status of this command is still unclear.  It is definitely
458reasonable to use compatible option names between server implementations
459where applicable, but the set of useful configuration parameters
460seems to be impossible to specify in advance.
461Any comment on this issue is welcome.
462
463<sect2> <tt> show </tt>
464<p>
465
466Show a configuration parameter value. The parameter is an option
467name. The server may reply with the value of the option requested,
468preceded by a single space character, or it may ignore this command
469with error code 442.
470
471<tt/show languages/ and <tt/show voices/ may be used for listing
472available languages, as well as available voices for the current
473language.  The language or voice names are given on separate lines
474each.
475
476<sect2> <tt> strm </tt> <label id="strm-cmd">
477<p>
478
479Prepare a data flow stream. The parameter is a colon-separated sequence
480of data processing modules; commands such as <tt/appl/ cause specified
481data to be run through the modules from left to right.
482Any two adjacent modules must be compatible, that is the type of output
483produced by the one to the left must match the type of input processed by the
484one to the right. The leftmost module must designate a source (input) module
485for the whole stream, the rightmost one must designate a destination
486for the data produced by the stream. Information on specific data formats
487accepted or produced by the modules can be found <ref id="formats"
488name="above">.
489
490The stream is not automatically active. It processes data only when requested
491by the <ref id="appl-cmd" name = "appl"> command.
492
493The stream lasts until the next strm command or termination of
494the TTSCP connection, then it is deleted.
495
496<sect2> <tt> user </tt>
497<p>
498
499The <tt/user/ command is still not implemented properly and
500its semantics may change.  Epos is currently configured
501not to need and not to use it.  The tentative theory of
502TTSCP authentication goes as follows:
503
504The <tt/user/ command should precede all TTSCP exchanges. Its parameter is "anonymous"
505or a local or configured user account name. Some other user names
506may acquire special meaning. We'll see.
507
508Unless the account requires no authentication, this command
509should be immediately followed by a proper pass command;
510otherwise the session may be refused to issue most or all
511other commands.
512
513If no <tt/user/ command is issued, "user anonymous" is assumed.
514
515If the user doesn't exist, anonymous access is granted.
516
517
518<sect1> TTSCP Modules
519
520<sect2> Input and Output Modules
521<p>
522
523The input and output modules follow the same syntax conventions.
524If the module name begins with a <tt/&dollar;/, the rest of the name
525is a data connection handle. If it begins with a slash, it is
526an absolute file name.  Such absolute file names however form a name
527space distinct from that of the underlying operating system.  In Epos, the
528name space is a single directory defined by the <ref id="pseudorootdir-option"
529name="<tt/pseudo_root_dir/">
530option.  It must be impossible to escape from such name space by inserting
531parent directory references in a file name or otherwise.  A TTSCP
532implementation can decide to reject some or all file input and output modules
533with a 454 reply.
534
535If the module name begins with a <tt/&num;/, the rest of the name is a special
536input/output module identifier.  The only identifier generally supported is
537<tt/localsound/, which can only be used as an output module with the <tt/waveform/
538type.  Any waveform passed to this module should be played over using the
539local soundcard.  The <tt/453/ or <tt/445/ reply may be issued if the
540user is not allowed to use the soundcard, or no local soundcard exists,
541respectively.
542
543The output data type of an input module and the input data type of an output
544module are determined by the respective adjacent modules. If input and
545output modules are directly connected, it is assumed that the data is
546a plain text.
547
548The TSR data type can not be sent or received, and may thus be totally
549implementation and architecture dependent.
550
551
552
553<sect2> Processing Modules
554<p>
555
556At the moment there are only few modules implemented that do a real
557processing. All of them have fixed names and types.
558
559<table loc="ht">
560<tabular ca="|l|l|l|l|">
561<hline>
562 name	  | input format | output format | notes@
563<hline>
564 chunk	  | plain text	| plain text		| splits text @
565 join	  | plain text	| plain text		| joins texts @
566 raw	  | plain text	| TSR			| parses text @
567 stml	  | STML text	| TSR			| parses STML @
568 rules	  | TSR		| TSR			| apply rules @
569 print	  | TSR		| plain text		| @
570 dump	  | TSR		| SSIF			| extract SSIF @
571 diphs	  | TSR		| segments		| extract segments @
572 syn	  | SSIF	| waveform		| speech synthesis @
573 synth	  | segments	| waveform		| speech synthesis @
574<hline>
575</tabular>
576<caption> Available processing modules </caption>
577</table>
578
579<sect3> <tt> chunk </tt> <label id="chunk-mod">
580<p>
581
582The text is split into parts convenient for latter processing.
583These parts usually correspond at least to whole utterances;
584it is correct not to split the text at all, but care must be
585taken not to cause a split which significantly alters the
586final rendering of the text.
587
588<sect3> <tt> join </tt> <label id="join-mod">
589<p>
590
591It is customary to use the <tt/join/ module just after a <tt/chunk/ module.
592If this module receives two consecutive texts such that the <tt/chunk/
593module would not split their concatenation between them, the <tt/join/ module
594may merge them to a single text, that is, it may silently drop the first
595subtask and prepend the text to the text acquired later.  This delay
596may cross the boundary of an <tt/appl/ command.
597
598<sect3> <tt> raw </tt>
599<p>
600
601The input text is converted in a language dependent way to the TSR,
602assuming it is a plain text without any specific TTS escape sequences
603or other special formatting conventions.  Except for tokenization
604and whitespace reduction the conversion should not try to process
605the text, especially not in a language dependent way; this goal
606doesn't seem to be always feasible.
607
608<sect3> <tt> rules </tt>
609<p>
610
611The voice dependent TTS or other rules are applied to a TSR.
612
613<sect3> <tt> print </tt>
614<p>
615
616The TSR is converted to a plain text representation, suitable as a
617user-readable output.  The conversion should be as straightforward
618as possible and should not emit any special formatting character
619sequences.  Ideally, the successive application of the <tt/raw/ and
620<tt/print/ modules should not significantly alter the text.
621
622<sect3> <tt> dump </tt>
623<p>
624
625...
626
627<sect3> <tt> diphs </tt>
628<p>
629
630This module extracts the segment layer from the input TSR into
631the linear segment stream format; the rest of TSR is discarded.
632
633There may be an implementation-dependent limit on the size
634of the segment stream produced.  If more segments should be produced,
635the module may emit more subtasks; see the <ref id="appl-cmd"
636name="appl"> command for discussion concerning subtask reporting.
637t
638
639<sect3> <tt> synth </tt>
640<p>
641
642The input segment stream is synthesized in a voice dependent way.
643
644
645
646
647<sect2> Explicit Data Type Specifiers
648<p>
649
650Sometimes an ambiguity concerning the type of data passed at a certain point
651within the stream may occur.  This is currently the case with streams consisting
652of input and output modules only (such as a stream to play out an audio icon
653from a waveform file to a sound card device); in the future, ambiguously
654typed versatile processing modules may be introduced, too.  Sometimes the
655data type is semantically irrelevant (for example, a socket-to-socket
656forwarding stream), sometimes the default data type, that is, a plain text,
657is a reasonable choice.  There are however instances where the type matters,
658like copying a waveform file to a sound card device: the waveform header
659must be stripped off and the appropriate <tt/ioctl/s must be issued to
660replay the raw waveform data with the appropriate sampling frequency, sample
661size and so on.
662
663The data types can be expressed explicitly by inserting a pseudo-module
664into the stream at the ambiguous position.  Failing that, the output data
665type of the preceding module and/or the input data type decides the data
666type at this point. Failing even that, the server will assume plain text
667data.
668
669The pseudo-module name consists of a single letter enclosed in square
670brackets.  The available data types are indicated by letters listed in
671<ref id="typespecs" name="the table of explicit data type specifiers">.
672
673<table loc="ht">
674<tabular ca="|l|l">
675<hline>
676<label id="typespecs">
677 name	       | data format @
678<hline>
679 t | plain text  @
680 s | STML text  @
681 i | the server-internal text structure representation @
682 p | SSIF @
683 d | segments @
684 w | waveform @
685<hline>
686</tabular>
687<caption> Explicit data type specifiers </caption>
688</table>
689
690The data formats are described in <ref id="formats"
691name="the data formats subsection">.
692
693
694
695
696
697<sect1>Response Codes
698<p>
699
700Any server <em/reply/ contains a numeric code, a single space, and some
701arbitrary newline-terminated text. The numeric code (three decimal
702digits) allows interfacing with simple to trivial clients, whereas
703the text (which is optional) is meant for possible user interaction.
704
705The <em/response codes/ are defined by the protocol, while the accompanying
706text is not, but it should rarely exceed 20 characters (clients
707should tolerate at least 76 characters plus the response code).
708
709Every response code consists of the <em/response class/, <em/the subclass/
710and an extra digit. The response class drives the protocol states
711and reports errors. The subclass is interpreted depending on the
712response class; it can specify which component has reported
713an error or generated this particular response. Trivial clients
714may ignore this digit altogether. The third digit is merely used
715for distinguishing between messages of the same class and subclass
716and most clients are likely to ignore it in most situations.
717
718<sect2>Response Classes
719<p>
720Within TTSCP, nine response classes have been defined.
721Out of these, one is used for in-progress communication,
722four indicate the results of commands, and the remaining
723four are reserved for future extensions.
724
725<table loc="ht">
726<tabular ca = "|l|l|l|">
727<hline>
728code | error type | suggested action @
729<hline>
7300xx | reserved  | (server queries client?) @
7311xx | still OK | informative only @
7322xx | OK, command completed | transmit another command @
7333xx | reserved | notify user / ignore @
7344xx | command failed | transmit another command @
7355xx | reserved | notify user @
7366xx | connection terminated | notify user if unexpected @
7377xx | reserved  | notify user @
7388xx | server crash or shutdown | notify user @
739<hline>
740</tabular>
741<caption>
742	TTSCP response classes
743</caption>
744</table>
745
746The client is expected to send another command whenever it receives
747a 2xx or a 4xx response, not to send otherwise. The client should
748treat the connection as terminated, whenever it receives any response
749with code 5xx or higher. It may also quit at any time just after
750sending a "done" command to the server; the server will however
751confirm that command with a reply of 600 before disconnecting.
752
753Replies of 8xx except 80x are reserved for cases of severe server
754misconfiguration, or detected programming bugs. Their meanings
755are very implementation dependent (implementations are encouraged
756not to issue them except in emergency). If such a reply is ever
757received, the server has abnormally terminated.
758
759The messages accompanying 3xx and higher response codes are likely
760to be interesting to the user if there is one. Any message without an error
761code is a data flow primarily meant for the user if any; a sequence
762of these may occur only after some 1xx response, except for debugging
763messages if on.
764
765At the moment, some error codes contain letters. Later, all of
766them will consist of digits only and will be space-terminated.
767
768<sect2> Response Subclasses
769<p>
770
771The subclass depends on the response class. The most interesting
772classes are 3xx and 4xx, i.e. errors, where the subclass indicates
773both the nature of the problem, and the suggested way of dealing
774with it (especially in the case of 4xx responses).
775The same meaning is attached to these subclasses also in case
776of 6xx and 8xx responses.
777
778The middle digit of 1xx and 2xx responses has still no meaning
779attached (there are only a few such responses).
780
781<table loc="ht">
782<tabular ca="|l|l|l|">
783<hline>
784code      | error type      | suggested action@
785<hline>
7860         | none            | relax; assume user-initiated interruption@
7871         | syntax          | notify user@
7882         | busy or timing  | wait and retry@
7893         | bad data        | notify user@
7904         | not found       | notify user@
7915         | access denied   | notify user@
7926         | server error    | have user notify server author@
7937         | network error   | wait and retry@
794<hline>
795</tabular>
796<caption>
797	TTSCP error subclasses
798</caption>
799</table>
800
801<sect2> Currently Defined Messages
802<p>
803
804<table loc="htp">
805<tabular ca="|l|l|">
806<hline>
807111	| daemon talks@
808112	| apply task started@
809122	| apply task total bytes count follows@
810123	| apply task chunk bytes count follows@
811141	| option value follows@
812142	| data connection handle follows@
813<hline>
814200	| daemon is happy and ready@
815211	| access granted@
816212	| anonymous access granted@
817<hline>
818</tabular>
819<caption>
820	TTSCP success codes as issued by Epos
821</caption>
822</table>
823
824<table loc="hptb">
825<tabular ca="|l|l|">
826<hline>
827401	| intr command received@
828411	| command not recognized@
829412	| option passed illegal value@
830413	| command too long, ignored@
831414	| parameter should be a positive integer@
832415	| no or bad stream@
833416	| no parameter allowed@
834417	| parameter missing@
835418	| bad format or encoding@
836421	| output voice busy@
837422	| out of memory@
838423	| nothing to interrupt@
839431	| unknown character in text@
840432	| received bad segments@
841435	| received bad waveform (unused)@
842436	| data connection disconnected@
843437	| permanent read error@
844438	| end of file@
845439	| hw cannot handle this waveform@
846441	| help not available@
847442	| no such option@
848443	| no such language or voice@
849444	| invalid connection handle@
850445	| could not open file@
851446	| out of range (never issued)@
852447	| invalid option value@
853448	| cannot send woven pointery@
854451	| not authorized to do this@
855452	| no such user or bad password@
856453	| not allowed to use localsound@
857454	| not allowed to use filesystem input/output modules@
858456	| input too long@
859461	| input triggered server bug@
860462	| unimplemented feature@
861463	| input triggered configuration bug@
862464	| input triggered OS incompatibility@
863465	| i/o problem : error on close()@
864466	| command stuck@
865467	| fatal signal@
866471	| tcpsyn received invalid waveform@
867472	| unresolved remote tcpsyn server@
868473	| unreachable remote tcpsyn server@
869474	| remote tcpsyn server uses an unknown protocol@
870475	| remote tcpsyn server returned error@
871476	| remote tcpsyn server timed out@
872<hline>
873</tabular>
874<caption>
875	TTSCP error codes as issued by Epos
876</caption>
877</table>
878
879The 8xx class of responses (fatal errors) is still very unsettled
880and many of the codes listed there
881will later be removed or merged together. Applications should not try to decode
882them except possibly for the middle digit. The same goes for all x6x subclasses
883of errors (internal errors).
884
885<table loc="htbp">
886<tabular ca="|l|l|">
887<hline>
888600	| session ended normally@
889601	| server reinitializing as requested@
890<hline>
891800	| server shutting down as requested by client@
892801	| error explicitly reported in config files@
893811	| rules or dictionary file syntax@
894812	| generic configuration file syntax@
895813	| impossibilia referenced in config files@
896814	| bad command line@
897841	| cannot open necessary configuration file@
898842	| no voices configured@
899843	| up-to-date configuration files not found@
900844	| no unicode or SAMPA maps found@
901861	| internal error: impossible branch of execution@
902862	| internal error: invariance violation@
903863	| internal error: buffer overflow@
904864	| insufficient capacity@
905865	| server crashed, reason unspecified@
906869	| double fault@
907871	| network unreachable@
908872	| server already running@
909881	| too many syntax errors in rule files@
910882	| infinite include cycle@
911<hline>
912</tabular>
913<caption>
914	TTSCP session termination codes as issued by Epos
915</caption>
916</table>
917
918