# Adding a grammar in a VoiceXML file

The VoiceXML specification http://www.w3.org/TR/voicexml21/ requires all valid spoken and telephone key-press inputs to be specified using a grammar. You can add grammars to your application in two ways:

- Coding the grammar inline (that is, within your VoiceXML file)
- Creating and referencing an external grammar (specified in a separate grammar file)

This topic includes the following information:

- Coding an inline grammar
- Referencing an external grammar
- Referencing an audio file

#### Coding an inline grammar

Use one of the following methods:

- Specify the <grammar>. . .</grammar> tags in your VoiceXML file.
- Code the grammar within a menu/choice construct.

#### Referencing an external grammar

After you create a grammar file, code a reference to it in your VoiceXML file. For example, to use the external grammar file "mygrammar," you would use the following code:

    <grammar src = "mygrammar.grxml" type="application/srgs+xml" />

#### Referencing an audio file

To use an audio file, specify the URI in your VoiceXML file <audio src= filename >.

Related Information
Speech Recognition Grammar Specification
Semantic Interpretation for Speech Recognition