FilePrompt Constructor (String, SynthesisMediaType)


Creates a new instance of the FilePrompt class, and specifies the path to the file and its media type.

Namespace:   System.Speech.Synthesis
Assembly:  System.Speech (in System.Speech.dll)

public FilePrompt(
	string path,
	SynthesisMediaType media


Type: System.String

The path of the file containing the prompt content.

Type: System.Speech.Synthesis.SynthesisMediaType

The media type of the file.

You can use this class to create an object from an existing Speech Synthesis Markup Language (SSML) file that the SpeechSynthesizer can consume to generate speech.

The example that follows creates a FilePrompt object that specifies a path to an SSML prompt. To speak the contents of the prompt, the example then provides the FilePrompt object as the argument to the Speak method.

using System;
using System.Speech.Synthesis;

namespace SampleSynthesis
    class Program
        static void Main(string[] args)

            // Initialize a new instance of the SpeechSynthesizer.
            using (SpeechSynthesizer synth = new SpeechSynthesizer())

                // Configure the audio output. 

                // Create a FilePrompt object that references an SSML prompt.
                FilePrompt ssmlFile = new FilePrompt("c:\\test\\Weather.ssml", SynthesisMediaType.Ssml);

                // Speak the contents of the SSML prompt.

            Console.WriteLine("Press any key to exit...");

The following is the SSML file that the preceding example references.

<?xml version="1.0" encoding="ISO-8859-1"?>
<speak version="1.0"

  <s> The weather forecast for today is partly cloudy with some sun breaks. </s>


.NET Framework
Available since 3.0
Return to top