Share via


prompt Element

  Microsoft Speech Technologies Homepage

Specifies the content of audio output.

<prompt attributes>
   <param attributes />    // Custom configuration (optional)
   prompt text
   <content attributes />  // References external output resources 
   prompt text
   <value attributes />    // Associates values from page elements
</prompt>

The prompt element consists of the following members:

Contents Description
param Specifies a configuration parameter for the Speech Platform.
content Refers to an external output resource.
value Retrieves the value of an element in an HTML document.
Inline prompt content Specifies inline prompt content.
Attributes Description
bargein Specifies whether the prompt is cut off when the user speaks or dual tone multi-frequency (DTMF) input is received. Optional.
id Uniquely identifies the prompt element.
prefetch Specifies whether the prompt should be fetched (for remote files) or synthesized immediately and cached when the page is loaded. Optional.
lang Specifies the language to which the prompt refers. Optional.
xmlns Declares a namespace and identifies the schema of the format. Optional.
Properties Description
status Returns the status code from the last operation. Read-only.
reason Returns contextual information about the most recent error if that information can be determined by the Speech Platform. Read-only. Does not apply to telephony applications.
Methods Description
Start Starts prompt playback.
Pause Pauses playback without flushing the audio buffer. Microsoft-specific for Speech Add-in for Microsoft Internet Explorer. For Telephony Application Services, this method applies to the PromptQueue object.
Resume Resumes playback without flushing the audio buffer. Microsoft-specific for Speech Add-in for Microsoft Internet Explorer. For Telephony Application Services, this method applies to the PromptQueue object.
Stop Stops playback and flushes the audio buffer. Microsoft-specific for Speech Add-in for Microsoft Internet Explorer. For Telephony Application Services, this method applies to the PromptQueue object.
Events Description
onbargein Occurs when prompt playback is still in progress and when an input event is detected by sound, DTMF input, or speech from the user.
oncomplete Occurs when the prompt playback ends successfully.
onerror Occurs when a serious or fatal error occurs with the text-to-speech (voice output) process.

Remarks

A prompt is content spoken to the user. Prompts can perform a variety of tasks. For example, a prompt can:

  • Provide instructions (such as telling users how to proceed)
  • Confirm actions (repeating input parameters that the user has spoken so the user has an opportunity to confirm or correct selections)
  • Read text
  • Greet users

The prompt element contains resources for speech output. Spoken content is supplied as either text or audio files, or both. Text content exists as plain text or XML content that is enhanced with Speech Synthesis Markup Language (SSML) markup.

Any number of prompt elements can be declared on a page and any prompt can be used more than once. However, a separate prompt element should be declared for each unique purpose in a prompt. In other words, create a separate prompt element for each separate thing that needs to be spoken to the user. For example, a page may only need one prompt for all speaking purposes. The following prompt could be declared for a page.

<salt:prompt id="Prompt1">Please say your name, last name first</salt:prompt>

If it is determined later that even a single instance of the prompt needs an additional attribute, such as adding an oncomplete event-handler, declare another prompt. Existing prompts cannot be programmatically modified after declaration to include new attributes or delete existing ones. The following declaration is a new prompt element for the page and includes the oncomplete event.

<salt:prompt id="Prompt2" oncomplete="doCompleted()" >Please say your name, last name first</salt:prompt>

Because the purpose of prompts is to speak back to the user, the content of that speech must be specified. There are four ways to specify this prompt text.

  1. Inline text. Inline text is specified in the prompt element definition. If parameter text is not present when calling the Start method, text that is declared inline in the prompt element declaration is used. The following example demonstrates a simple case.

    <salt:prompt id="Welcome">
    Thank you for calling ACME weather report.
    </prompt>
    

  2. Referenced prompt. Another method to generate prompt speech is to use an external source file. The source file can be either a text-only file or an audio file. If the source file contains only text, the entire file content is spoken to the user. An audio file, however, is played for the user. The path to a referenced path can be relative to the current directory or an absolute path to the file. The prompts can exist on a different server, but as long as a network connection is established, the source file can be accessed. The following example opens a text file named welcome.ssml.

    <salt:prompt id="Prompt1">
    <salt:content type="application/ssml+xml" href="welcome.ssml" />
    </salt:prompt>
    
    The following example uses a .wav audio file. The behavior of the page is identical to that of the preceding example except that the referenced prompt is an audio file. FakePre-8f2cc44d8ee6493998688356827914da-87c0a92a68774baa90fb1fe79a9c0e7f

  3. Prompt Database. The prompt database is the audio collection used by the speech engines. Rather than synthesizing speech, the database manages a collection of custom-recorded .wav files. Individual files may be long, depending on the needs of the speech application programmer. Individual files can be concatenated together to produce the necessary prompts. Speech Control Editor simplifies recording, editing, and managing prompts in the prompt database.

    When using a prompt database in a SALT page, it is necessary to define the PromptEngine workspace with an xmlns attribute, as shown in the following example.

    <html xmlns:salt="http://www.saltforum.org/2002/SALT"
    xmlns:pe="https://schemas.microsoft.com/Speech/2003/03/PromptEngine">
    ...
    <salt:prompt id="Prompt1">
    <pe:prompt_output>
    <pe:database fname="http://cpandl.com/Prompts/SpeechApps.prompts" />
    Welcome to City Power and Light.
    </pe:prompt_output>
    </salt:prompt>
    ...
    </html>
    A collection of prerecorded audio prompts can be put into a database and referenced within that database.

  4. Parameter text. Simple prompts need to specify only the text required for output. By default, the parameter text of the Start method is determined first. Any text that is present as a parameter is used as the prompt. The text string can be hard coded using a string literal. The following code demonstrates a literal prompt used as the parameter text.

    Prompt1.start("Thank you for calling ACME weather report.");
    The prompt can also be a string variable that is assigned a value before use. Using a variable, the actual content of the prompt can change on the client just before its use. In order to confirm a particular value, for example, the value needs to be dereferenced into a variable. Use the value element for this purpose. Though not technically considered a dynamic allocation, a variable provides a robust method for changing text while the application is running.

The prompt elements can be played individually and, in more complex applications, they can be managed through prompt queuing. Prompts are queued and played in subqueues. In Microsoft Internet Explorer, subqueue manipulation is available using the PromptQueue object.

See Also

dtmf Element | listen Element | PromptQueue Object |  smex element